using System; using System.Collections.Generic; using System.IO; using System.Linq; 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 */ Console.ReadLine(); var values = Console.ReadLine().ToCharArray().ToList(); var number = 0; var count = 0; values.ForEach( val => { number = val == 'U' ? number + 1 : number - 1; if (val == 'U' && number == 0) { count++; } }); Console.WriteLine(count); } }