#include <bits/stdc++.h>
using namespace std;
signed main() {
  string S;
  cin >> S;
  while (1) {
    string X;
    for (long long i = (long long)(0); i < (long long)(S.size() - 1); i++) {
      if (S[i] == 'S' && S[i + 1] == 'T')
        i++;
      else
        X += S[i];
    }
    if (S[S.size() - 1] == 'T') {
      if (S[S.size() - 2] == 'T') X += S[S.size() - 1];
    } else
      X += S[S.size() - 1];
    if (X.size() == S.size() || X.size() == 0) {
      cout << X.size() << endl;
      break;
    }
    S = X;
  }
}
