import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int numberOfSteps = in.nextInt(); int[] heights = new int[numberOfSteps + 1]; String steps = in.next(); char[] c = steps.toCharArray(); heights[0] = 0; for(int i = 0; i < numberOfSteps; i++) { if(c[i] == 'U') heights[i+1] = heights[i] + 1; else heights[i+1] = heights[i] - 1; } int numberOfValleys = 0; boolean inAValley = false; for(int i = 1; i < heights.length; i ++) { if(heights[i] < 0 && !inAValley ) { numberOfValleys++; inAValley = true; } else if(heights[i] == 0) inAValley = false; } System.out.println(numberOfValleys); } }