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