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) { int valleys = 0; int seaLevel = 0; boolean startValley = false; Scanner in = new Scanner(System.in); int num = in.nextInt(); String movement = in.next(); char [] move = movement.toCharArray(); for(int i = 0; i < num;i++){ if(move[i] == 'U'){ seaLevel++; } if(move[i] == 'D'){ seaLevel--; } if(seaLevel == 0 && startValley == true){ valleys++; startValley = false; } if(seaLevel < 0){ startValley = true; } } System.out.println(valleys); /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ } }