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 in = new Scanner(System.in); in.nextLine(); String path = in.nextLine(); char[] steps = path.toCharArray(); int elevation = 0; int valleys = 0; for(int i = 0; i < steps.length; i++){ if(steps[i] == 'U'){ if(elevation == -1){ valleys++; } elevation++; } else if(steps[i] == 'D'){ elevation--; } } System.out.println(valleys); } }