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 keyboard = new Scanner(System.in); int numSteps = keyboard.nextInt(); int stepsFromSea = 0; int valleys = 0; int hills = 0; String steps = keyboard.next(); for (int i = 0; i < numSteps; i++){ char stepDir = steps.charAt(i); if(stepDir == 'U'){ stepsFromSea++; if(stepsFromSea == 0){ valleys++; } } else { stepsFromSea--; if(stepsFromSea == 0){ hills++; } } } System.out.println(valleys); } }