/* Programming Competition - Template (Horatiu Lazu) */ import java.io.*; import java.util.*; import java.lang.*; import java.awt.*; import java.awt.geom.*; import java.math.*; import java.text.*; class ProblemB{ BufferedReader in; StringTokenizer st; public static void main (String [] args){ new ProblemB(); } public ProblemB(){ try{ in = new BufferedReader(new InputStreamReader(System.in)); int N = nextInt(); String p = next(); int current = 0; boolean start = false; boolean prevUp = false; //UDDDUDUU int mountains = 0; int valleys = 0; for(int x = 0; x < p.length(); x++){ if (p.charAt(x) == 'U'){ current++; if (!start){ prevUp = true; start = true; } if (current == 0){ valleys++; } } else if (p.charAt(x) == 'D'){ current--; if (!start){ prevUp = false; start = true; } if (current == 0){ mountains++; } } } System.out.println(valleys); } catch(IOException e){ System.out.println("IO: General"); } } String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine().trim()); return st.nextToken(); } long nextLong() throws IOException { return Long.parseLong(next()); } int nextInt() throws IOException { return Integer.parseInt(next()); } double nextDouble() throws IOException { return Double.parseDouble(next()); } String nextLine() throws IOException { return in.readLine().trim(); } }