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