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