import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); char[] steps = in.next().toCharArray(); int level = 0; int h = 0; for( char step : steps){ if( step == 'U'){ level++; if( level == 0 ){ h++; level = 0; } } else { level--; } } System.out.println(h); } }