using System; using System.Collections.Generic; using System.IO; class Solution { public static class Hike{ private static int _intLength; private static List _intSteps = new List(); public static List Steps{ get { return _intSteps; } set { _intSteps = value; } } public static int Length{ get { return _intLength; } set { _intLength = value; } } public static void ReadLine(string value){ foreach(char chr in value.ToCharArray()){ switch(chr){ case 'U': Steps.Add(1); break; default: Steps.Add(-1); break; } } } public static void FindValleys(){ int seaLevel = 0; int valleyCount = 0; bool bIsAbove = true; foreach(int step in Steps){ seaLevel += step; if (seaLevel < 0){ if(bIsAbove){ valleyCount++; bIsAbove = false; } } else { bIsAbove = true; } } Console.WriteLine(valleyCount); } } static void Main(String[] args) { Hike.Length = Convert.ToInt32(Console.ReadLine().Trim()); Hike.ReadLine(Console.ReadLine().Trim()); Hike.FindValleys(); } }