using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); int level = 0; int count = 0; bool bls = true; string str = Console.ReadLine(); foreach(char s in str) { if(s == 'U') level = level + 1; else { level = level - 1; } if(level < 0 && bls) { bls = false; count++; } if(level == 0) bls = true; } Console.WriteLine(count); } }