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 steps = Convert.ToInt32(Console.ReadLine()); string directions = Console.ReadLine(); int seaLevel = 0; bool valleyStarted = false; int valleyCounter = 0; foreach (char c in directions){ if ( c == 'U'){ seaLevel++; } else if(c == 'D'){ seaLevel--; } if(seaLevel == -1 && !valleyStarted){ valleyStarted = true; } if(seaLevel == 0 && valleyStarted){ valleyStarted = false; valleyCounter++; } } Console.WriteLine(valleyCounter); } }