#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[200002];
  cin >> s;
  int a;
  for (int i = strlen(s) - 1; i > -1; i--) {
    if (s[i] == 'T') {
      a = 2 * (strlen(s) - 1 - i);
      break;
    }
  }
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == 'S') {
      if (a < 2 * i) a = 2 * i;
      break;
    }
  }
  cout << a << endl;
}
