#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  bool erased = true;
  while (erased) {
    if (X.size() == 0) break;
    erased = false;
    for (int i = 0; i < X.size() - 1; i++) {
      if (X[i] == 'S' && X[i + 1] == 'T') {
        X = X.substr(0, i) + X.substr(i + 2);
        erased = true;
        break;
      }
    }
  }
  cout << X.size() << endl;
}
