#include <bits/stdc++.h>
using namespace std;
string str;
int main() {
  cin >> str;
  int n;
  while ((n = str.find("ST")) != string::npos) {
    str.erase(n, n + 1);
  }
  if (str.length() == 1)
    cout << 0 << endl;
  else
    cout << str.length() << endl;
  return 0;
}
