#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  bool ok = true;
  int s = (int)str.find("ST");
  while (ok) {
    if (s == -1) {
      ok = false;
      break;
    } else {
      str.erase(str.begin() + s);
      str.erase(str.begin() + s);
      s = -1;
    }
    s = (int)str.find("ST");
  }
  cout << str.size() << endl;
  return 0;
}
