# Enter your code here. Read input from STDIN. Print output to STDOUT num_valleys = 0 curr_sea_level = 0 total_steps = int(raw_input().strip()) step_map = list(str(raw_input().strip())) for step in step_map: if 'U' == step: curr_sea_level += 1 if 'D' == step: if curr_sea_level == 0: num_valleys += 1 curr_sea_level -= 1 print(num_valleys)