#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;
int main(int argc, char *argv[]) {
  string X;
  cin >> X;
  while (X.find("ST") != string::npos) {
    X.replace(X.find("ST"), 2, "");
  }
  cout << X.size() << endl;
  return 0;
}
