N = int(input()) steps = input() height = 0 v_count = 0 for step in steps: if step == 'U': height += 1 else: height -= 1 if step == 'D' and height == -1: v_count += 1 print(v_count)