import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int current_level = 0; int valley = 0; int mountain = 0; String str = in.next(); char[] level = str.toCharArray(); for(int x=0; x < n; x++) { if(current_level == 0) { if(level[x] == 'U') mountain++; else if(level[x] == 'D') valley++; } if(level[x]=='U') current_level++; else if(level[x]=='D') current_level--; } System.out.println(valley); } }