using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { Console.ReadLine(); string steps = Console.ReadLine(); Console.WriteLine(NumberOfValleys(steps)); } static int NumberOfValleys(string steps){ int level = 0; int valleys = 0; foreach (var step in steps){ if (step == 'U'){ level++; if (level == 0){ valleys++; } } if (step == 'D'){ level--; } } return valleys; } }