#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
    int n;
    scanf("%d\n", &n);
    int level = 0;
    int volley_count = 0;
    for (int i = 0; i < n; i++) {
        char step;
        scanf("%c", &step);
        int prev_level = level;
        if (step == 'U') {
            level++;    
        }
        if (step == 'D') {
            level--;
        }
        if (prev_level == -1 && level == 0) {
            volley_count++;   
        }
        //printf("%c - %d\n", step, level);
    }    
    printf("%d", volley_count);
    return 0;
}