import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String d = in.next(); char[] charArray = new char[n]; charArray = d.toCharArray(); int[] intArray = new int[n]; for(int i = 0; i < n; i++) { if(charArray[i] == 'U') intArray[i] = 1; else intArray[i] = -1; } int level = 0; int finalCount = 0; for(int c = 0; c < n; c++) { if(level == 0) { if(intArray[c] == -1) finalCount++; } level += intArray[c]; } System.out.print(finalCount); } }