steps = int(input()) steps_path = input() current_height = 0 valley_counter = 0 for step in steps_path: if step == "U": current_height +=1 else: if current_height == 0: valley_counter += 1 current_height -=1 print(valley_counter)