using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string steps = Console.ReadLine(); int height = 0; bool inValley = false; int ValleyCount = 0; for (int i = 0; i < n; i++) { char s = steps[i]; if (s == 'D') { height--; if (height == -1 && !inValley) { inValley = true; } } else if (s == 'U') { height++; if (height == 0 && inValley) { inValley = false; ValleyCount++; } } } Console.WriteLine(ValleyCount); } }