#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string x;
  cin >> x;
  const int n = x.size();
  int tidx = 0, sidx = n - 1;
  while (tidx < n and x[tidx] == 'T') tidx++;
  while (sidx >= 0 and x[sidx] == 'S') sidx--;
  cout << 2 * max(tidx, n - 1 - sidx) << endl;
  return 0;
}
