#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int len = X.size();
  int rt = X.rfind("T");
  int ls = X.find("S");
  int nt, ns;
  nt = ns = 0;
  for (int i = ls; i <= rt; i++) {
    nt += (X[i] == 'T');
    ns += (X[i] == 'S');
  }
  int res = max(nt, ns) - min(nt, ns);
  cout << ls + (len - rt - 1) + res << endl;
  return 0;
}
