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) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner scn = new Scanner(System.in); int inSize = scn.nextInt(); String userInput = scn.next(); char[] charIn = userInput.toCharArray(); int up =0; int down =0; int numOfValleys = 0; for(int i=0 ;i< inSize ; i++){ if(charIn[i]== 'U'){ up++; if(up!=0 && down !=0 && up-down==0 ){ numOfValleys++; } }else{ down++; } } System.out.println(numOfValleys); } }