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) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ int alt = 0; int count = 0; Scanner in = new Scanner(System.in); int n = Integer.parseInt(in.nextLine()); String a = in.nextLine(); for (int i = 0; i < n; i++) { if (a.substring(i, i+1).equals("D")) { alt--; } else { alt++; } if (alt == 0 && a.substring(i, i+1).equals("U")) { count++; } } System.out.println(count); } }