#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int N = s.size();
  bool a = true, b = true;
  for (int i = 0; i < N; i++) {
    if (a && s[i] == 'S') a = false;
    if (b && s[N - 1 - i] == 'T') b = false;
    if (!(a || b)) {
      cout << i * 2 << endl;
      return 0;
    }
  }
}
