import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { final Scanner in = new Scanner(System.in); int n = in.nextInt(); char[] ch = in.next().toCharArray(); int s = 0; int v = 0; boolean started = false; for (int i = 0; i < n; i++) { if (ch[i] == 'U') { s++; if (s == 0 && started) { v++; started = false; } } else if (ch[i] == 'D') { s--; if (!started) { started = true; } } } System.out.println(v); in.close(); } }