import java.io.*; import java.util.*; 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 stdIn = new Scanner(System.in); int numberOfSteps = Integer.parseInt(stdIn.nextLine()); String hikeString = stdIn.nextLine(); int numOfValleysTraveled = 0; int currentElevation = 0; for(int i = 0; i < hikeString.length(); i++){ char nextStep = hikeString.charAt(i); if(nextStep == 'U'){ if(currentElevation + 1 == 0){ numOfValleysTraveled += 1; } currentElevation += 1; } else if(nextStep == 'D'){ currentElevation -= 1; } } System.out.print(numOfValleysTraveled); } }