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) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner kb = new Scanner(System.in); int numSteps = kb.nextInt(); kb.nextLine(); String steps = kb.nextLine(); int toSeaLevel = 0; int numValleys = 0; // int numMountains = 0; for (int i = 0; i < numSteps; i++) { if (steps.charAt(i) == 'U') { toSeaLevel++; if (toSeaLevel == 0) { numValleys++; } } else if (steps.charAt(i) == 'D') { toSeaLevel--; } } System.out.println(numValleys); } }