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 steps = in.nextInt(); in.nextLine(); String line = in.nextLine(); int valley = 0; int level = 0; for (int i = 0; i < steps; i++) { if(line.charAt(i) == 'U') { level++; if (level == 0) { valley++; } } else { level--; } } System.out.println(valley); } }