#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int s;
  for (int i = 0; i < X.size(); i++) {
    if (X[i] == 'S') {
      s = i;
      break;
    }
  }
  int t;
  for (int i = X.size(); i >= 0; i--) {
    if (X[i] == 'T') {
      t = i + 1;
      break;
    }
  }
  t = X.size() - t;
  int ans = max(s, t) * 2;
  cout << ans << endl;
  return 0;
}
