using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string hike = Console.ReadLine(); int steps = 0; int valley = 0; for (int i = 0; i < n; i++) { if (hike[i] == 'U') { steps++; } if (hike[i] == 'D') { steps--; } if (steps == 0 && hike[i] == 'U') { valley++; } } Console.WriteLine(valley); //Console.ReadKey(); } }