#include<bits/stdc++.h>
using namespace std;
int main(){
  string X;cin >> X;
  int cntS = 0;
  int ans = N;
  int N = X.size();
  for(int i = 0; i < N; ++i){
    if(X[i] == 'S')cntS++;
    else if(cntS > 0){
      cntS--;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
