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 scan = new Scanner(System.in); int numSteps = scan.nextInt(); scan.nextLine(); String steps = scan.nextLine(); int altitude = 0; int numValleys = 0; for(int i = 0; i < numSteps; i++){ if (steps.charAt(i) == 'U'){ altitude++; }else{ altitude--; if (altitude == -1) numValleys++; } } System.out.println(numValleys); } }