# Enter your code here. Read input from STDIN. Print output to STDOUT n=raw_input() s=raw_input() lvl=0 count=0 if(int(n)==len(s)): for st in s: lvlp=lvl if(st=='U'): lvl+=1 else: lvl=lvl-1 if lvlp==0 and lvl==-1: count+=1 print count