using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ int numSteps = Convert.ToInt32(Console.ReadLine()); string steps = Console.ReadLine(); int sealevel = 0; int numValleys = 0; foreach(char c in steps.ToUpper()) { int previous = sealevel; if(c == 'U') { sealevel++; } else { sealevel--; } if(sealevel == 0 && previous < 0) { numValleys++; } } Console.WriteLine(numValleys); } }