using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int total = Convert.ToInt32(Console.ReadLine()); bool isGoingUp = false; int level = 0; int valleyCount = 0; string input = Console.ReadLine(); int inputLength = input.Length; string[] steps = new string[inputLength]; for(int i = 0; i < inputLength; i++) { steps[i] = input.Substring(i, 1); } for (int i = 0; i < inputLength; i++){ if (steps[i].Equals("U")) { level++; isGoingUp = true; } else if (steps[i].Equals("D")) { level--; isGoingUp = false; } if (level == 0 && isGoingUp) { valleyCount++; } } Console.Write(valleyCount); } }