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 scan = new Scanner(System.in); //int stepCount = scan.nextInt(); scan.nextLine(); String steps = scan.next(); char[] chars = steps.toCharArray(); int currentLevel = 0; int previousLevel = 0; int walleyCount = 0; for(char c : chars) { previousLevel = currentLevel; if(c == 'U') { currentLevel++; } else { currentLevel--; } if(currentLevel >=0 && previousLevel < 0) { walleyCount++; } } System.out.print(walleyCount); } }