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 heightAboveSeaLevel = 0; int noValleys = 0; int noSteps = int.Parse(Console.ReadLine()); string stepProfile = Console.ReadLine(); for (int i=0; i < noSteps; i++) { // Console.WriteLine(stepProfile[i]); char currentStep = stepProfile[i]; if (stepProfile[i] == 'U') { heightAboveSeaLevel++; if (heightAboveSeaLevel == 0) noValleys++; } else if (stepProfile[i] == 'D') { heightAboveSeaLevel--; } } Console.WriteLine(noValleys); } }