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 */ var length = Convert.ToInt64(Console.ReadLine()); var steps = Console.ReadLine().ToCharArray(); var level = 0; var valleyCount = 0; for (long i = 0; i < length; i++) { if (steps[i] == 'U') { level++; } else { level--; } if (level == 0 && steps[i] == 'U') { valleyCount++; } } Console.WriteLine(valleyCount); } }