N = int(input()) steps = input() count = 0 valleys = 0 for c in steps: if c == 'U': count += 1 if count == 0: valleys += 1 elif c == 'D': count -= 1 print(valleys)