import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int i=scan.nextInt(); int level=0; String s=""; int valley=0; int prevlevel=0; for(int j=0;j<=i;j++) { s=scan.next(); if(s.equals("U")) level=level+1; if(s.equals("D")) level=level-1; if(prevlevel<0 && level>=0) { valley=valley+1; } prevlevel=level; } System.out.println(valley); } }