num = int(input().strip()) steps=input().strip() valleyCnt,level = 0,0 for step in steps: if step=='D': level = level - 1 elif step == 'U': level = level + 1 if level == 0: valleyCnt += 1 print(valleyCnt)