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();
        char[] hike = new char[n];
        in.nextLine();
        String hikeString = in.nextLine();
        hike = hikeString.toCharArray();
        int pos = 0;
        boolean seaLevel = true;
        int valleys = 0;
        for (char c : hike) {
            if (pos == 0) {
                seaLevel = true;
            }
            if (c == 'U') {
                pos++;
                if (seaLevel) {
                    seaLevel = false;
                }
            }
            else if (c == 'D') {
                pos--;
                if (seaLevel) {
                    valleys++;
                    seaLevel = false;
                }
            }
        }
        System.out.println(valleys);
    }
}