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 sc = new Scanner(System.in); String strSteps = sc.nextLine(); int steps = Integer.parseInt(strSteps); String hike = sc.nextLine(); if (hike.length() < 3){ System.out.println(0); return; } int cntr = 0; int lvl = 0; int lastLvl = 0; for (int i = 0; i < hike.length(); i++){ if(hike.charAt(i) == 'U') { lvl++; if (lastLvl < 0 && lvl == 0) cntr++; } else if(hike.charAt(i) == 'D') lvl--; lastLvl = lvl; } System.out.println(cntr); } }