# Enter your code here. Read input from STDIN. Print output to STDOUT raw_input() level = 0 valleys = 0 for step in raw_input().strip(): if step == "U": level += 1 if (level-1) == -1: valleys += 1 elif step == "D": level -= 1 print(valleys)