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 = Integer.parseInt(in.nextLine()); char[] ud = in.nextLine().toCharArray(); int elevation = 0; int valleyNum = 0; for(int i = 0; i < steps; i++) { if(ud[i] == 'U') { elevation++; } else { if(elevation == 0) { valleyNum++; } elevation--; } } System.out.println(valleyNum); } }