# Enter your code here. Read input from STDIN. Print output to STDOUT n=int(raw_input()) ud=list(raw_input().strip()) count=0 value=0 for i in range (n): if ud[i]=='D' : count -= 1 if ud[i]=='U': count += 1 if count==0 and ud[i]=='U': value += 1 print value