#include <bits/stdc++.h>
using namespace std;
int main() {
  char buf[262144];
  scanf("%s", buf);
  string X(buf);
  size_t pos = 0;
  while (X.find("ST") != string::npos) {
    pos = X.find("ST", pos);
    X.erase(X.begin() + pos, X.begin() + pos + 2);
  }
  printf("%llu\n", X.length());
}
