import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ try(Scanner in = new Scanner(System.in)) { int numSteps = in.nextInt(); in.nextLine(); int numValleys = 0; boolean inValley = false; int height = 0; for(char c : in.nextLine().toCharArray()) { if(c == 'U') { height++; } else { height--; } if(height == 0 && inValley) { inValley = false; numValleys++; } else if(height < 0) { inValley = true; } } System.out.println(numValleys); } } }