//https://www.hackerrank.com/contests/rookierank/challenges/birthday-cake-candles 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 in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); String s = in.nextLine(); int valleys = 0, level = 0, past1 = 0; //boolean in_valley = false; for(int i = 0; i < n; i++){ //if (level == 0 && s.charAt(i) == 'D') { // in_valley = true; //} if (level == -1 && s.charAt(i) == 'U') { //in_valley = false; valleys++; } past1 = level; if (s.charAt(i) == 'D') {level--;} else {level++;} } System.out.println(valleys); } }