# Enter your code here. Read input from STDIN. Print output to STDOUT import sys n = int(raw_input().strip()) l = raw_input() ln = [] for i in l: if i == 'U': ln.append(1) else: ln.append(-1) count = 0 x = 0 for i in ln: x += i if x == -1 and i == -1: count += 1 print count