import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int testCase = sc.nextInt(); String[] steps = sc.next().split(""); // ArrayList al=new ArrayList(); // // for (int i = 0; i < testCase; i++) { // al.add(sc.next()); // } int seaLevel = 0; int previousSeaLevel = 0; int valley = 0; int size = steps.length; for (int i = 0; i < size; i++) { String s = steps[i]; if (s.equalsIgnoreCase("U")) { seaLevel++; //System.out.println("sea level U :"+seaLevel); } else { seaLevel--; //System.out.println("sea level D :"+seaLevel); } if (seaLevel == 0 && previousSeaLevel <= 0) { valley++; } previousSeaLevel = seaLevel; } System.out.println(valley); } }