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. */ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int level = 0; int numValley = 0; String input = scanner.next(); for (int i = 0; i < n; i++) { char move = input.charAt(i); if (move == 'U') { if (level == -1) numValley++; level++; } else if (move == 'D') { level--; } } System.out.println(numValley); } }