import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); String s = scanner.next(); char[] chars = s.toCharArray(); int h = 0, count = 0; boolean isInValley = false; for (char c : chars) { if (c=='U') h++; else h--; if (h<0) isInValley = true; if (h==0 && isInValley) { count++; isInValley = false; } } System.out.println(count); } }