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); int noOfSteps = in.nextInt(); String entireLine = in.next(); int level = 0; int valleyCount = 0; for(int i = 0; i < entireLine.length(); i++) { char temp = entireLine.charAt(i); if(temp == 'U') { if(level == -1) { valleyCount++; } level++; } else if (temp == 'D') { level--; } } System.out.println(valleyCount); } }