n = int(input()) line = input() currentLevel = 0 valleys = 0 for i in range(n): if line[i] == 'U': if currentLevel == -1: valleys += 1 currentLevel += 1 elif line[i] == 'D': currentLevel -= 1 print(valleys)