import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static final char UPHILL = 'U'; static final char DOWNHILL = 'D'; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); String steps = scan.next(); int valleysCount = 0; int currentLevel = 0; for (int i = 0; i < n; i++) { if (steps.charAt(i) == UPHILL) { currentLevel += 1; } else { if (currentLevel == 0) { valleysCount += 1; } currentLevel -= 1; } } System.out.println(valleysCount); } }