# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(input()) steps = raw_input() h=0 v=0 count=0 for c in steps: if c == "U": h+=1 else: h-=1 if h<0 and v == 0: count+=1 v=1 if h>=0: v = 0 print count