n=eval(input()) a=input() w=int(n/2) c=0 for i in range(0,len(a)): if a[i]=='D': w-=1 elif a[i]=='U': w+=1 if w==int(n/2): c+=1 print(c)