# Enter your code here. Read input from STDIN. Print output to STDOUT num_steps = raw_input() steps = raw_input() level = 0 valey = 0 previous = 0 for i in steps: if i == "D": previous = level level+= -1 if i == 'U': previous = level level+= 1 if previous == -1 and level == 0: valey +=1 print valey