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 sc = new Scanner(System.in); int stepCount = sc.nextInt(); sc.nextLine(); String steps = sc.nextLine(); int valleys = 0; int height = 0; boolean valleyStart = false; int previousHeight = 0; for (int i = 0; i < stepCount; i++) { if (steps.charAt(i) == 'U') { height++; if (height == 0 && valleyStart) { valleys++; valleyStart = false; } } else { if (previousHeight == 0) { valleyStart = true; } height--; } previousHeight = height; } System.out.println(valleys); } }