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 sc = new Scanner(System.in); int N = sc.nextInt(); String hike = sc.next(); int elevation = 0; int valleys = 0; for (int s = 0; s < hike.length(); s++) { if (hike.charAt(s) == 'U') { elevation++; // exiting a valley if (elevation == 0) { valleys++; } } else { elevation--; } } System.out.println(valleys); sc.close(); } }