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. */ int height = 0; boolean inValley = false; int numValleys = 0; Scanner s = new Scanner(System.in); int numSteps = s.nextInt(); s.nextLine(); String directions = s.nextLine(); for(int i = 0; i < numSteps; i++) { if(directions.charAt(i)=='U') { height++; } else { height--; } if(height<0 && !inValley) { numValleys++; inValley = true; } if(height >= 0 && inValley) { inValley = false; } } System.out.println(numValleys); } }