using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int n = int.Parse(Console.ReadLine()); char[] array = Console.ReadLine().ToCharArray(); int level = 0; int valley = 0; bool startMountain = false; foreach (var step in array) { if (step == 'U') { if (level == 0) startMountain = true; level++; } else { if (level == 0) startMountain = false; level--; } if (level == 0 && startMountain == false) valley++; } Console.WriteLine(valley); } }