# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(raw_input().strip()) steps = raw_input() valley = 0 current = 0 for i in range(len(steps)): if steps[i] == 'U': current += 1 if steps[i] == 'D': current -= 1 if current == 0: if steps[i] == 'U': valley += 1 print valley