#include<iostream>
#include<string>
using namespace std;

int main(){
  string s;
  cin>>s;
  int scount=0,ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='S')++scount;
    else if(scount>0){
      scount--;
      ans+=2;
    }
  }
  cout<<s.size()-ans<<endl;
}