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. */ Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); int elevation_tracker = 0; int valley_counter = 0; boolean valley_status = false; String path = in.next(); for (int index = 0; index < n; index++){ char aChar = path.charAt(index); if (aChar == 'U'){ elevation_tracker++; } else{ elevation_tracker--; } if (elevation_tracker < 0){ valley_status = true; } else{ if (valley_status == true){ valley_counter++; valley_status = false; } else{ } } } System.out.println(valley_counter); } }