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) { Scanner s = new Scanner(System.in); int size = s.nextInt(); String path = s.next(); int height = 0; boolean startOfValley=false; int count = 0; for(int i = 0; i < size; i++){ Character c = path.charAt(i); if(c == 'U'){ height++; } if(c == 'D'){ height--; } if(height == -1){ startOfValley = true; continue; } if(startOfValley && height == 0){ count++; startOfValley = false; } } System.out.println(count); } }