import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String v = sc.next(); int[] degrees = new int[n + 1]; degrees[0] = 0; for (int i = 1; i <= n; i++) { if (v.charAt(i - 1) == 'U') degrees[i] = degrees[i - 1] + 1; else degrees[i] = degrees[i - 1] - 1; } int count = 0; for (int j = 1; j <=n; j++) { if (degrees[j - 1] < 0 && degrees[j] >= 0) count++; } System.out.println(count); sc.close(); } }