import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int steps = scan.nextInt(); String sequence = scan.next(); int level = 0; int numValleys = 0; for(int i = 0; i < steps; i++) { char curr = sequence.charAt(i); if(curr == 'U') { level++; if(level == 0) { numValleys++; } } if(curr == 'D') level --; } System.out.println(numValleys); } }