#include<cstdio>
char x[200001];
int main(){
    scanf("%s",x);
    int h=0,minh=0;
    for(int i=0;x[i]!='\0';i++){
        if(x[i]=='S')h++;
        else {
            h--;
            if(h<minh)minh=h;
        }
    }
    printf("%d",-2*minh);
    return 0;
}