#!/bin/python import sys n = int(raw_input().strip()) directions = raw_input().strip() sea_level = 0 valleys_amount = 0 for step in directions: if step == 'U': sea_level += 1 elif step == 'D': if sea_level == 0: valleys_amount += 1 sea_level -= 1 print valleys_amount