#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  string X;
  cin>>X;
 
  while(1){
    if(n==X.length())break;
    for(int i=0;i<X.length();i++){
      if(X[i]=='S'&&X[i+1]=='T'){
	X.erase(X.begin()+i,X.begin()+i+2);
	X[i]=X[i+1]=x;
      }
    }
    n=X.length();
  }
  
  cout<<X.length()<<endl;
 
  return 0;
}
