import sys N=int(input().strip()) Steps=input().strip() N=0 Count=0 for step in Steps: if N==0: Start=step if step=='U': N+=1 else: N+=-1 if N==0 and Start=='D': Count+=1 print(Count)