#include<iostream>
using namespace std;
int main(){
  int s,t,i,length,count;
  string N;
  s = 0;
  t = 0;
  count = 0;
  cin >> N;
  length = N.size();
  for(i=0;i<length;i++){
    if(N[i] == 'S'){
      S++;
      if(S-T=>0)
        count++;
    }
    else{
      T++;
      if(S-T=>0)
        count++;
    }
  }
  cout << length-2*count << "\n";
  return 0;
}