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) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ int sea_Level = 0; int valleys = 0; Scanner in = new Scanner(System.in); String steps = in.nextLine(); String steps_String = in.nextLine(); for (int step_Count = 0; step_Count < Integer.parseInt(steps); step_Count++){ if (steps_String.charAt(step_Count) == 'U') { sea_Level++; } else { sea_Level--; } if ((sea_Level == 0) && (steps_String.charAt(step_Count) == 'U')){ valleys++; } } System.out.println(valleys); } }