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 first = scan.nextInt(); scan.nextLine(); String second = scan.nextLine(); char[] array = second.toCharArray(); int valley = 0, value = 0; boolean flag = false; for (int i = 0; i < array.length; i++) { if (array[i] == 'D') { flag = true; value++; }else if (array[i] == 'U'){ value--; if (value == 0 && flag){ valley++; flag = false; } } } System.out.println(valley); } }