import java.io.*; import java.util.*; public class Solution { private static char UP = 'U'; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); scan.nextLine(); String steps = scan.nextLine(); scan.close(); int height = 0; // 0 means sea level int valleyCount = 0; for(int i = 0; i < n; i++) { char step = steps.charAt(i); if (height == -1 && step == UP) { valleyCount++; } if (step == UP) { height++; } else { height--; } } System.out.println(valleyCount); } }