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) throws IOException { InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); int n = Integer.parseInt(br.readLine()); char steps[] = new char[n]; for(int i=0; i < n; i++){ steps[i] = (char)br.read(); } int sealevel=0; int valleys =0; for(int i=0; i < n; i++){ if (steps[i]=='U') sealevel++; if (steps[i]=='D') sealevel--; if (steps[i]=='U'&&sealevel==0) valleys++; } System.out.println(valleys); } }