import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int numSteps = in.nextInt(); String steps = in.next(); int numVall = 0; int counter = 0; //Sea level 0, step down -1, step up +1 for(int x = 0; x < numSteps; x++) { int prev = counter; if(steps.charAt(x) == 'U') { counter++; } else if (steps.charAt(x) == 'D') { counter--; } if(prev < 0 && counter == 0) { numVall++; } } System.out.println(numVall); } }