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 n = in.nextInt(); in.nextLine(); char steps[] = in.nextLine().toCharArray(); int level = 0; boolean inValley = false; int valleys = 0; for(int i = 0; i < steps.length; i++) { char s = steps[i]; if(s == 'D' && level == 0) { //Entering valley inValley = true; } else if (s == 'U' && level == -1) { //Exit valley inValley = false; valleys++; } level += (s == 'D' ? -1 : 1); } System.out.println(valleys); } }