import java.io.*; import java.util.*; 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 input = new Scanner(System.in); int n =input.nextInt(); char[] sequence = new char[n]; String stuff = input.next(); int elevation = 0; int numberOfValleys = 0; boolean atZero = false; for(int k = 0; k < n; k++) sequence[k] = stuff.charAt(k); for(int i = 0; i < n; i++){ if(elevation == 0 && sequence[i] == 'D') numberOfValleys++; if(sequence[i] == 'U') elevation++; else if(sequence[i] == 'D') elevation = elevation - 1; } System.out.println(numberOfValleys); } }