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 scan = new Scanner(System.in); int n = scan.nextInt(); scan.nextLine(); String steps = scan.nextLine(); char[] stepsChar = new char[n]; stepsChar = steps.toCharArray(); int moveUp = 0; int moveDown = 0; int valley = 0; boolean bellow = true; for (int i = 0; i < n; i++) { if (stepsChar[i] == 'D') { moveDown++; moveUp--; } else { moveDown--; moveUp++; } if (moveDown > 0) { bellow = true; } if (bellow == true && moveDown == moveUp) { valley++; } if (moveDown <= 0) { bellow = false; } } System.out.println(valley); } }