import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println(valleys(Integer.parseInt(sc.nextLine()), sc.nextLine().toCharArray())); } private static int valleys(int steps, char[] dirs){ int valleys = 0; int level = 0; for(char dir: dirs){ if (level==0&&dir=='D') valleys++; if(dir=='D') level--; else if (dir=='U') level++; } return valleys; } }