# Enter your code here. Read input from STDIN. Print output to STDOUT N=int(raw_input()) Steps=raw_input().strip() def getValleys(steps=None): countValleys=0 StepsSum=0 for each in steps: if each=="U": add=1 else: add=-1 if StepsSum==0: if each=="D": countValleys=countValleys+1 StepsSum=StepsSum+add print countValleys getValleys(Steps)