# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(raw_input().strip()) steps = list(raw_input().strip()) level = 0 is_valley = False res = 0 for step in steps: if step == 'D': level = level -1 elif step == 'U': level = level + 1 if is_valley: if level == 0: is_valley = False else: if level < 0: is_valley = True res = res+1 print res