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 scanner = new Scanner(System.in); int n = scanner.nextInt(); String steps = scanner.next(); int level = 0; // 0 implies sea level int noValleys = 0; for (int i = 0; i < n; i++) { char step = steps.charAt(i); if (step == 'U') { level++; } else if (step == 'D') { if (level == 0) { noValleys++; } level--; } } System.out.println(noValleys); } }