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(); String input = scanner.next(); int seaLevel = 0; int count = 0; boolean hisDown = false; for (int i = 0; i < input.length(); i++) { if (input.charAt(i) == 'U') seaLevel++; else if (input.charAt(i) == 'D') seaLevel--; if (seaLevel < 0 && hisDown == false){ hisDown = true; count++; } else if (seaLevel >= 0 && hisDown == true ){ hisDown = false; } } System.out.println(count); } }