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) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int len = sc.nextInt(); String map = sc.next(); // Sea level = 0, Mountain = 1, Valley = -1 int state = 0, valleyCnt = 0, sum = 0; for(int i = 0; i < len; i++) { char c = map.charAt(i); if(state == 0 && c == 'D') { valleyCnt++; } if(c == 'U') { sum++; } else { sum--; } if(sum > 0) { state = 1; } else if(sum == 0) { state = 0; } else { state = -1; } } System.out.println(valleyCnt); } }