#include <bits/stdc++.h>
using namespace std;
string str;
int main() {
  cin >> str;
  bool ok = true;
  while (ok) {
    int i = str.find("ST");
    if (i != std::string::npos) {
      str.erase(i, 2);
    } else {
      ok = false;
    }
  }
  cout << str.size() << endl;
  return 0;
}
