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