#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int ans,x;
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='T')x++;
        else x--;
        ans=max(ans,x);
    }
    cout<<ans*2<<endl;
    return 0;
}