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 seaLevel=0, numberOfValley=0,upNumber=0,downNumber=0; Scanner in = new Scanner(System.in); int t = in.nextInt(); String a = new String(); a = in.next(); boolean isValley=false; //System.out.println(a); for(int a_i=0; a_i < t; a_i++){ if(a.charAt(a_i) == 'U'){ upNumber+=1; seaLevel+=1; }else if(a.charAt(a_i) == 'D'){ downNumber+=1; seaLevel-=1; } if(seaLevel<0) isValley=true; else isValley=false; if(seaLevel== -1 && a.charAt(a_i)=='D' && isValley) { numberOfValley++; } } System.out.println(numberOfValley); } }