import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int numberOfSteps = scanner.nextInt(); String hike = scanner.next(); scanner.close(); int height = 0; int valleys = 0; for (int i = 0; i < numberOfSteps; i++) { char step = hike.charAt(i); if (step == 'U') { height++; } else { height--; } if (height == 0 && step == 'U') { valleys++; } } System.out.println(valleys); } }