import sys n=int(raw_input().strip()) steps=str(raw_input()) c=[] def checkValley(steps): sealevel=0 Mcount=0 Vcount=0 for j in range(0,len(steps)): if steps[j]=='U': sealevel+=1 if sealevel==0: Vcount+=1 #Mcount+=0.5 elif steps[j]=='D': sealevel-=1 if sealevel==0: Mcount+=1 #Vcount+=0.5 print(Vcount) checkValley(steps)