n=int(input()) steps=input() l=[] for x in steps: l.append(x) level=0 mountain=0 valley=0 for step in l: if(step=='U'): if(level==0): mountain+=1 level+=1 if(step=='D'): if(level==0): valley+=1 level-=1 print(valley)