import java.io.*; import java.util.*; 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 scan = new Scanner(System.in); scan.nextLine(); String input = scan.nextLine(); int count = 0; int valleyCount = 0; int index = 0; for(char c : input.toCharArray()){ if(c == 'U') { count++; } else{ count--; } if(index!=0 && count == 0 && c =='U'){ valleyCount++; } index++; } System.out.println(valleyCount); } }