# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(raw_input()) s = raw_input() elev = 0 valleys = 0 for i in s: if i == 'D': if elev == 0: valleys += 1 elev -= 1 elif i == 'U': elev += 1 print valleys