using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string steps = Console.ReadLine(); int level = 0; int valleys = 0; foreach (var step in steps) { int newLevel = level + (step == 'U' ? 1 : -1); if (newLevel == 0 && level < 0) { valleys++; } level = newLevel; } Console.WriteLine(valleys); } }