#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  while (S.find("ST") != S.npos) {
    size_t pos = 0;
    while ((pos = S.find("ST", pos)) != S.npos) {
      S.replace(pos, 2, "");
      pos++;
    }
  }
  cout << S.length() << endl;
}
