#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  while (x.find("ST") != string::npos) {
    int p = x.find("ST");
    x = x.substr(0, p) + x.substr(p + 2, x.size() - p - 2);
  }
  cout << x.size() << endl;
}
