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 */ Console.ReadLine(); string str = Console.ReadLine(); int status = 0; int valleyCount = 0 ; int previousValue = 0; foreach(char ch in str){ previousValue = status; if(ch == 'U'){ status++; } else if(ch == 'D'){ status--; } if(status == 0 && previousValue < 0) valleyCount++; } Console.WriteLine(valleyCount); } }