import sys buf = [] while True: line = sys.stdin.readline().strip('\n') if line: buf.append(line) else: break if buf: n = int(buf[0]) num_down = 0 num_up = 0 prev_step = '' val = 0 for i in range(n): step = buf[1][i] if step == "D": num_down += 1 if num_down == 1 and not num_up: val += 1 if step == "U": num_up += 1 if num_up == num_down: num_up = 0 num_down = 0 prev_step = step print(val)