#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int countS, countT, l = -1, r = 0;
  while (l != r) {
    countS = countT = l = r = 0;
    for (int i = 0; i < X.size(); ++i) {
      if (X[i] == 'S') {
        if (countS != 0 && countT != 0) {
          r = i - (countT - min(countS, countT));
          l = i - countT - min(countS, countT);
          break;
        }
        ++countS;
      } else {
        if (countS == 0) {
          continue;
        } else {
          ++countT;
        }
      }
    }
    X = X.substr(0, l) + X.substr(r, X.size() - r);
  }
  cout << X.size() << endl;
}
