import java.io.*; import java.util.*; 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 steps = scan.nextInt(); String s = scan.next(); boolean inValley = false; int level = 0; int valleys = 0; for (int i = 0; i < s.length(); i++){ char step = s.charAt(i); if (step == 'U'){ level++; if (inValley && level == 0){ inValley = false; } } else { level--; if (!inValley && level < 0){ inValley = true; valleys++; } } } System.out.println(valleys); } }