#include <bits/stdc++.h>
using namespace std;

const int MN = 2e5+5;
int cnt, rem;
string s;

int main(){
    cin >> s; rem = s.size();
    for(char c : s){
        if(c=='S') cnt++;
        else if(cnt) cnt--, rem-=2;
    }
    printf("%d\n",rem);
    return 0;
}
