# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(raw_input().strip()) hike = list(raw_input().strip()) lvl = 0 v = 0 for step in hike: if step == 'U': if lvl == -1: v += 1 lvl += 1 else: lvl -= 1 print v