import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String str = sc.next(); int alt = 0; int valcount = 0; int hillovall = 0; char[] car = str.toCharArray(); for(int i = 0; i < n; i++){ if(car[i] == 'U'){ alt++; } else { alt--; } if(alt > 0){ hillovall = 1; } else if(alt < 0) { hillovall = -1; } if(alt == 0 && hillovall == -1){ valcount++; } } System.out.println(valcount++); } }