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) { Scanner in = new Scanner(System.in); int steps = (int)Integer.parseInt(in.nextLine()); String path = in.nextLine(); int elevation = 0; int valleys = 0; int prevElevation = 0; for (int i = 0; i < path.length(); i++){ if (path.charAt(i) == 'U') { prevElevation = elevation++; } else if (path.charAt(i) == 'D') { prevElevation = elevation--; } if (elevation < 0 && prevElevation >=0){ valleys++; } } System.out.println(valleys); } }