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 scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.useDelimiter(""); scanner.next(); int h = 0; int valleys = 0; int prev; for (int i = 0; i < n; ++i) { prev = h; if (scanner.next().charAt(0) == 'U') { if (prev == -1) { ++valleys; } ++h; } else { --h; } } scanner.close(); System.out.println(valleys); } }