#include <bits/stdc++.h>
using namespace std;
bool eraseSubStr(string& mainStr, const string& toErase) {
  size_t pos = mainStr.find(toErase);
  if (pos != std::string::npos) {
    mainStr.erase(pos, toErase.length());
    return true;
  }
  return false;
}
int main() {
  string X;
  cin >> X;
  while (true) {
    if (!eraseSubStr(X, "ST")) break;
  }
  cout << X.length() << endl;
}
