import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); bufferedReader.readLine(); String path = bufferedReader.readLine(); String[] pathSplit = path.split(""); int valleys = 0, hills = 0; int currentLevel = 0; for (String pathItem : pathSplit) { if (pathItem.equals("U")) { currentLevel++; } else { if (currentLevel == 0) { valleys++; } currentLevel--; } } System.out.println(valleys); } }