#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  string X;
  cin >> X;
  while (true) {
    int pos = X.find("ST");
    if (pos == string::npos) {
      break;
    } else {
      X.erase(pos, 2);
    }
  }
  cout << X.length() << endl;
  return 0;
}
