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

int main()
{
  string s;
  cin>>s;
  
  int cs = 0;
  int cnt =0;
  for (int i =0;i<s.length();i++)
  {
    if (s[i]=='S')
      cs++;
    else if (s[i]=='T'&&cs>0)
    {
      cs--;
      cnt++;
    }
  }
  cour << s.length()- cnt*2 << endl;
}
    
