elevation = 0 valleys = 0 n = int(input().strip()) height = input() for movement in height: if movement == "D": elevation -= 1 if movement == "U": elevation += 1 if elevation == 0: valleys += 1 print(valleys)