# Enter your code here. Read input from STDIN. Print output to STDOUT n=input() str1=str(raw_input()) s=0 c=0 for i in range(0,len(str1)): if str1[i]=='U': s=s+1 if str1[i]=='D': s=s-1 if s==0 and i>0: if str1[i]=='U': c=c+1 print c