# Enter your code here. Read input from STDIN. Print output to STDOUT raw_input() steps = raw_input() height = 0 change = 0 for i in steps: if i == "U": height += 1 else: height -= 1 if height == 0 and i == "U": change += 1 print change