# Enter your code here. Read input from STDIN. Print output to STDOUT n=int(raw_input()) steps=raw_input() sea_level=0 enter_valley=False valley_count=0 for step in steps: if step=="U": sea_level+=1 else: sea_level-=1 if sea_level>0: continue if sea_level<0 and enter_valley==False: enter_valley=True valley_count=valley_count+1 if sea_level==0 and enter_valley==True: enter_valley=False print valley_count