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); Integer n = scanner.nextInt(); String steps = scanner.next(); char[] step = steps.toCharArray(); if(n != step.length) { return; } Stack stack = new Stack<>(); Integer count = 0; for (Integer i = 0; i < step.length; i++) { if (stack.isEmpty()) { stack.push(String.valueOf(step[i])); } else if (step[i] == 'D') { if (stack.peek().equals("U")) { stack.pop(); } else { stack.push(String.valueOf(step[i])); } } else if (step[i] == 'U') { if (stack.peek().equals("D")) { stack.pop(); if(stack.isEmpty()) { count++; } } else { stack.push(String.valueOf(step[i])); } } } System.out.println(count); scanner.close(); } }