using System; namespace Candles { public class Program { static void Main(string[] args) { int n = Int32.Parse(Console.ReadLine()); string input = Console.ReadLine(); int sealevel = 0; int valley = 0; int mountain = 0; int direction = input[0] == 'U' ? 0 : 1; foreach(var step in input.ToCharArray()) { if (step == 'U') { sealevel++; } else if (step == 'D') { sealevel--; } if(sealevel == 1 && direction == 0) { mountain++; } else if(sealevel == 0 && direction == 0) { direction = 1; } else if(sealevel == 0 && direction == 1) { valley++; } else if (sealevel == 1 && direction == 1) { direction = 0; } } Console.WriteLine(valley); } } }