import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); String s = scan.next(); char[] data = s.toCharArray(); int runCount = 0; int noOfVal = 0; boolean isBelowSea = false; for (char step : data) { if (step == 'U') { runCount++; } else { runCount--; } if(runCount < 0) { isBelowSea = true; } else if(runCount == 0 && isBelowSea) { noOfVal++; isBelowSea=false; } } System.out.println(noOfVal); } }