n = int(input().strip()) steps = input().strip() counter = 0 valleys = 0 for x in range(0,n): previousCounter = counter if steps[x] == "D": counter -= 1 else: counter += 1 if counter == 0: if previousCounter < 0: valleys += 1 print(str(valleys))