using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ int n = Convert.ToInt32(Console.ReadLine()); var s = Console.ReadLine(); int count = 0; var hike = new int[n]; int sum = 0; for (int i = 0; i < n; i++) { if (s[i] == 'U') hike[i] = 1; else hike[i] = -1; int prevSum = sum; sum += hike[i]; if (i > 0 && sum == 0 && prevSum < 0) count ++; } Console.WriteLine(count); } }