#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;
    scanf("%d",&n);
    char s[n];
    scanf("%s",&s);
    int count =0;
    int c =0;
    for(int i=0;i<n;i++){
        if((int)s[i]==68){
            count--;
        }
        else{count++;
            if(count ==0){c++;}
            }
    }
    cout<<c;
    return 0;
}