input() l = 0 v = 0 for s in input(): if s == 'U': l += 1 else: l -= 1 if l == -1: v += 1 print(v)