import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws Exception { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String input = in.readLine(); int s = Integer.parseInt(input); input = in.readLine(); int array[] = new int[s]; for(int i = 0; i < input.length(); ++i) { char c = input.charAt(i); if(c == 'U') array[i] = 1; if(c == 'D') array[i] = -1; } int res = 0; int start = 0; for(int i = 0; i < s; ++i) { start += array[i]; if(array[i] == -1 && start == -1) ++res; } System.out.println(res); } }