#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */  
	unsigned long n; cin >> n;
	string s; cin >> s;

	long elevation = 0;
	int num_valleys = 0;

	for(unsigned long i = 0; i < s.length(); i++){
		if(s[i] == 'U'){
			elevation++;
		}
		else if(s[i] == 'D'){
			if(elevation == 0)
				num_valleys++;

			elevation--;
		}
	}

	cout << num_valleys << endl;

    return 0;
}