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 in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); String s = in.next(); int seaLevel = 0; int lastSeaLevel = 0; int totalValleys = 0; for(int i = 0; i < n; i++){ if(s.charAt(i) == 'U'){ lastSeaLevel = seaLevel; seaLevel++; } else if(s.charAt(i) == 'D'){ lastSeaLevel = seaLevel; seaLevel--; } if(!checkValley(seaLevel, lastSeaLevel)){ totalValleys++; } } System.out.println(totalValleys); } public static boolean checkValley(int seaLevel, int lastSeaLevel){ if(seaLevel == 0 && lastSeaLevel == -1){ return false; } else{ return true; } } }