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 scan = new Scanner(System.in); int n = scan.nextInt(); int level = 0; int valleyCount = 0; String steps = scan.next(); for(int i = 0; i < n; i++) { char step = steps.charAt(i); if(step == 'D') { if(level-- == 0) { valleyCount++; } } else if(step == 'U') { level++; } } System.out.println(valleyCount); } }