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

int main(){
  int i,j,cnt=0;
  string x;
  cin>>x;
  int s=0,t=0;
  for(i=0;i<x.size();i++){
    if(x[i]=='S')s++;
    if(x[i]=='T'){
      if(s!=0)s--;
    }
  }
  cout<<2*s<<endl;
}