# Enter your code here. Read input from STDIN. Print output to STDOUT N = input() steps = raw_input() level = 0 valleys = 0 for s in steps: if s == 'D': level = level - 1 else: level = level + 1 if level == 0: valleys = valleys + 1 print valleys