import java.util.Scanner; public class Solution { public static void main(String[] args) { int count = 0; try (Scanner scanner = new Scanner(System.in)) { int n = scanner.nextInt(); int level = 0; scanner.nextLine(); String s = scanner.nextLine(); for (int i = 0; i < n; i++) { char c = s.charAt(i); boolean up = c == 'U'; int oldLevel = level; level += up ? 1 : -1; if (oldLevel < 0 && level == 0) { count++; } } } System.out.println(count); } }