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 scan = new Scanner(System.in); int N = scan.nextInt(); int numOfValleys = 0; int level = 0; int lastLevel = level; String steps = scan.next(); for(int i = 0; i < N; i++){ lastLevel = level; char step = steps.charAt(i); if(step == 'U'){ level++; } else if(step == 'D'){ level--; } if(lastLevel == 0 && level == -1){ numOfValleys++; } } /* Ended below sea level; Remove 1 valley from count */ if(level < 0){ numOfValleys--; } System.out.println(numOfValleys); } }