import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.nextLine(); String path = scanner.nextLine(); int valleys = 0; int prevHeight = 0; int height = 0; if (path.length() == 0) { System.out.println(valleys); return; } if (path.charAt(0) == 'U') { height = 1; } else { height = -1; } prevHeight = height; for (int i=1; i