using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string str = Console.ReadLine(); char[] arr = str.ToCharArray(); int currentLevel = 0; int numberOfValley = 0; bool valleyOver = true; for (int i = 0; i < n; i++) { if (arr[i] == 'U') { currentLevel++; } else { currentLevel--; } if (valleyOver && currentLevel == -1) { valleyOver = false; numberOfValley++; } if (currentLevel >= 0) { valleyOver = true; } } Console.WriteLine(numberOfValley); } }