  1 #include<bits/stdc++.h>
  2 
  3 
  4  #define sz(a) int((a).size()) 
  5  #define pb push_back 
  6 
  7  #define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
  8  #define present(c,x) ((c).find(x) != (c).end()) 
  9  #define cpresent(c,x) (find(all(c),x) != (c).end())
 10 using namespace std;
 11 
 12 typedef long long ll;
 13 
 14 int main()
 15 {
 16  string s;
 17  cin>>s;
 18 
 19  int l=s.length();
 20  int i=0;
 21  while(i!=l-1)
 22  {
 23         if(s[i]=='S'&&s[i+1]=='T')
 24         {
 25         s.erase(i,2);
 26         i--;
 27         }
 28         else
 29                 i++;
 30 
 31  }
 32  cout<<s.length();
 33 }
