import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int counter = 0; int valleyCounter = 0; boolean valleyFlag = false; boolean upFlag = false; String s = input.next(); char[] steps = s.toCharArray(); for (int i = 0; i < n; i++) { char step = steps[i]; if (step == 'D') { counter--; } else { counter++; upFlag = true; } if (counter < 0 && !valleyFlag) { valleyFlag = true; } else if (counter == 0 && valleyFlag && upFlag) { valleyCounter++; upFlag = false; valleyFlag = false; } } System.out.println(valleyCounter); } }