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