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 n = Convert.ToInt32(Console.ReadLine()), levelRespectSea = 0, numberOfValleys = 0; bool goingUp = false; while (n-- > 0) { char character = Convert.ToChar(Console.Read()); if (character == 'U') { goingUp = true; levelRespectSea++; } else { goingUp = false; levelRespectSea--; } if (levelRespectSea == 0 && goingUp == true) numberOfValleys++; } Console.WriteLine(numberOfValleys); } }