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 in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); String inputs = in.nextLine(); int move = 0; int valleys = 0; char c = 'a'; for(int i = 0; i < n; i++) { c = inputs.charAt(i); switch(c) { case 'U': move++; break; case 'D': move--; break; default: break; } if(move == -1 && inputs.charAt(i + 1) == 'U') { valleys++; } } System.out.println(valleys); } }