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