input() steps = input() altitude = 0 valleys = 0 for step in steps: if altitude == 0 and step == 'D': valleys += 1 altitude = altitude + 1 if step == 'U' else altitude - 1 print(valleys)