input() route = input().strip() height = 0 valleys = 0 for step in route: if step == 'U': height += 1 elif step == 'D': if height == 0: valleys += 1 height -= 1 print(valleys)