using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { var n = Convert.ToInt32(Console.ReadLine()); var steps = Console.ReadLine().ToArray(); var count = 0; var plain = new int[n+2]; for(var i = 1; i < n+1; i++){ plain[i] = plain[i-1] + (steps[i-1].Equals('U') ? 1 : -1); count += plain[i].Equals(0) && plain[i-1].Equals(-1) ? 1 : 0; } Console.WriteLine(count); } }