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 scan = new Scanner(System.in); int steps = Integer.parseInt(scan.nextLine()); String path = scan.nextLine(); int currHeight = 0, height = 0; int valleyNum = 0; for(int i = 0; i < path.length(); i ++) { if(path.substring(i,i+1).equals("U")) { height ++; } else if(path.substring(i,i+1).equals("D")) { height --; } if(currHeight == 0 && height == -1) { valleyNum ++; } currHeight = height; } System.out.println(valleyNum); } }