# Enter your code here. Read input from STDIN. Print output to STDOUT import sys n = int(sys.stdin.readline().strip()) data = list(sys.stdin.readline().strip()) level = 0 valleys = 0 for step in data: if step == 'U': level += 1 if level == 0: valleys += 1 if step == 'D': level -= 1 print valleys