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()); string input = Console.ReadLine(); bool valleyStart = false; bool valleyEnd = false; int count = 0; int valleyCount = 0; int status = 0; foreach(char c in input) { status++; if(c.Equals('U')) { count++; if (count == 0 && valleyStart == true) { valleyEnd = true; valleyCount++; } } if (c.Equals('D')) { count--; if(count==0) { valleyStart = true; } else if(status==1 && count==-1) valleyStart = true; } } Console.WriteLine(valleyCount); } }