#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  string str;
  cin >> str;
  while (str.find("ST") != string::npos) {
    str.erase(str.find("ST"), 2);
  }
  cout << str.size() << endl;
  return 0;
}
