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 scan = new Scanner(System.in); int n = scan.nextInt(); int step = 0; int count = 0; scan.nextLine(); String steps = scan.nextLine(); StringBuilder rep = new StringBuilder(); for(int i = 0; i < steps.length(); i++){ if(steps.charAt(i) == 'U') { step++; if(step == 0){ count++; } rep.append(step); } if(steps.charAt(i) == 'D') { step--; rep.append(step); } } /* String [] split = rep.toString().split("0"); for(int i = 0; i < split.length; i++){ // System.out.println(split[i]); if(split[i].startsWith("-1") && split[i].length() > 1) count++; } if(!rep.toString().endsWith("0")) count --; */ System.out.println(count); } }