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) { Scanner s = new Scanner(System.in); int mountain = 0; int valley = 0; int count=0; int N=s.nextInt(); boolean wasMountain = false; boolean wasValley = false; String steps=s.nextLine(); steps=s.nextLine(); for(int i=0;i0){ wasMountain = true; }if(count<0){ wasValley = true; //System.out.print("**"); } if(steps.charAt(i)=='U'){ ++count; }else if(steps.charAt(i)=='D'){ --count; } if(count==0){ if(wasMountain){ ++mountain; wasMountain = false; //System.out.print("M"); } if(wasValley){ ++valley; wasValley = false; //System.out.print("V"); } } } System.out.println(valley); } }