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 n = in.nextInt(); String steps = in.next(); int height = 0; int valleys = 0; boolean inValley = false; for(int i = 0; i < n; i++) { if(steps.charAt(i) == 'U') height++; if(steps.charAt(i) == 'D') height--; if(height < 0) inValley = true; if(height == 0 && inValley) { inValley = false; valleys++; } } System.out.println(valleys); } }