import java.io.*; import java.util.*; public class Solution { public static void main(String args[]){ int level = 0; int valCount = 0; Scanner s = new Scanner(System.in); int count = s.nextInt(); s.nextLine(); char ch[] = s.next().toCharArray(); for(int i = 0; i < count; i++){ if(ch[i] == 'U'){ level++; if(level == 0){ valCount++; } }else{ level--; } }//end for System.out.println(valCount); }//end of main }