import java.util.Scanner; public class Hiker { public static void main(String[] args) { final char UP = 'U', DOWN = 'D'; Scanner scan = new Scanner(System.in); int stepCount = scan.nextInt(); scan.nextLine(); String stepTrack = scan.nextLine(); scan.close(); char temp ; int valleyCount = 0, currentLevel = 0; boolean isDown = false; for(int stepIdx =0; stepIdx < stepTrack.length(); stepIdx++ ){ temp = stepTrack.charAt(stepIdx); if(temp == UP){ currentLevel++; isDown = false; }else{ isDown = true; currentLevel--; } if(!isDown && currentLevel == 0){ valleyCount++ ; } } System.out.print(valleyCount); } }