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 sc = new Scanner(System.in); int n = sc.nextInt(); char[] steps = sc.next().toCharArray(); int numValleys = 0; int hikerLevel = 0; int previousHikerLevel = 0; for(char step : steps){ if(step=='D'){ previousHikerLevel = hikerLevel; hikerLevel--; } else{ hikerLevel++; } if(hikerLevel < 0 && previousHikerLevel==0){ numValleys++; } } System.out.println(numValleys); } }