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

signed main(){
 string s; cin >> s;
 lint N = s.size();
 lint cs = 0, x = 0;
 for(lint i = 0; i < N; i++){
   if(s[i] == 'S') cs++;
   else{
     if(cs > 0) x++, cs--;
   }
 }
 cout << N - 2*x << endl;
}