# Enter your code here. Read input from STDIN. Print output to STDOUT import math n = int(raw_input().strip()) steps = str(raw_input().strip()) elevation = 0 valleys = 0 for step in steps: if elevation == 0 and step == 'D': valleys += 0.5 if step == 'D': elevation -= 1 elif step == 'U': elevation += 1 if elevation == 0 and step == 'U': valleys += 0.5 print int(math.floor(valleys))