# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(raw_input().strip()) steps = map(str,raw_input().strip()) pos = 0 valley = 0 for i in steps: if pos == 0 and i == 'D': valley += 1 if i == 'D': pos = pos - 1 elif i == 'U': pos = pos + 1 print valley