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 str = in.nextLine(); int valleys = 0; int lvl = 0; boolean below = false; for (String s: str.split("")){ if(lvl < 0) { below = true; } else { below = false; } if (s.equals("U")) { lvl++; } else if (s.equals("D")) { lvl--; } if(lvl == 0 && below) { valleys++; } } System.out.println(valleys); } }