#include <bits/stdc++.h>
using namespace std;
int Replace(string& ReplaceString, const char* srcStr, const char* trgStr) {
  string from = srcStr;
  string to = trgStr;
  string::size_type pos = 0;
  while (pos = ReplaceString.find(from, pos), pos != string::npos) {
    ReplaceString.replace(pos, from.length(), to);
    pos += to.length();
  }
  return 0;
}
int main(int argc, char* argv[]) {
  string str;
  cin >> str;
  Replace(str, "ST", "");
  Replace(str, "ST", "");
  cout << str.length() << endl;
  return 0;
}
