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 n = in.nextInt(); String stepStr = in.next(); String[] steps = new String[n]; for (int arr_i = 0; arr_i < n; arr_i++) { steps[arr_i] = String.valueOf(stepStr.charAt(arr_i)); } int altitude = 0; int valleyCount = 0; boolean inValley = false; for (int i = 0; i < n; i++) { if (steps[i].equals("U")) { altitude++; if (altitude == 0) { valleyCount++; } } else { altitude--; } } System.out.println(valleyCount); } }