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


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int n;
    cin>>n;
    string str;
    cin>>str;
    int height=0,cunt=0;
    int len=(int)str.size();
    for(int i=0;i<len;++i){
        
        if(str[i]=='D'){
            
            height--;
            
        }
        
        else{
            
            height++;
            
        }
        
        if(height==0){
            
            if(str[i]=='U')
                ++cunt;
            
        }
            
        
    }
    
    cout<<cunt<<"\n";
    return 0;
}