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 scanner = new Scanner(System.in);
        int N = 0;
        String str = null;
        
        if(scanner.hasNextInt()){
            N = scanner.nextInt();
        }else{
            System.exit(0);
        }
        
        if(scanner.hasNext()){
            str = scanner.next();
        }else{
            System.exit(0);
        }
        
        char[] steps = str.toCharArray();
        int currentLevel = 0;
        int noOfValleys = 0;
        
        for(int i=0;i<str.length();i++){
            if(steps[i] == 'D'){
                currentLevel--;
            }else if(steps[i] == 'U'){
                currentLevel++;
                if(currentLevel == 0){
                    //Reached sea level from a valley.
                    noOfValleys++;
                }
            }
        }
        
        System.out.println(noOfValleys);
        
    }
}