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