import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = Integer.parseInt(scan.nextLine()); String steps = scan.nextLine(); char[] stepsArr = steps.toCharArray(); int uCount = 0; int dCount = 0; int valleyCount = 0; for(char step : stepsArr) { if(step == 'U') { uCount++; } else { dCount++; } if(dCount == uCount && step == 'U') { valleyCount++; uCount = 0; dCount = 0; } } System.out.println(valleyCount); } }