#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin >> S;
  int count=0,ans=0;
  for (int i=0;i<S.size();i++){
  	if (S[i]=='T')count++;
    else count--;
    if (count>ans)ans=count;
  }
  cout << ans*2 <<endl;
}
