steps = int(input().strip()) s = input().strip() # U +1 # D -1 res = 0 stepsum = 0 beginwith = '' for step in s: if step == 'U': stepsum +=1 if not len(beginwith): beginwith = 'U' else: stepsum -=1 if not len(beginwith): beginwith = 'D' if stepsum == 0: if beginwith =='D': res +=1 stepsum = 0 beginwith = '' print(res)