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