#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  unsigned long long idx = 0;
  while ((idx = X.find("ST")) != string::npos) {
    X.erase(X.begin() + idx);
    X.erase(X.begin() + idx);
  }
  cout << X.size() << endl;
  return 0;
}
