#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  bool flag = false;
  while (1) {
    flag = false;
    if (X.find("ST") != string::npos) {
      X.erase(X.find("ST"), 2);
      flag = true;
    }
    if (!flag) break;
  }
  cout << X.length() << endl;
}
