# Enter your code here. Read input from STDIN. Print output to STDOUT num_steps = int(raw_input()) steps = [i for i in raw_input()] stack = 0 total = 0 for i in steps: if i == "D": stack += 1 else: stack -= 1 if stack == 0: total += 1 print total