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