#include <bits/stdc++.h>
using namespace std;
signed main() {
  string S;
  cin >> S;
  long long A;
  long long B;
  for (long long i = 0; i < S.size(); i++) {
    if (S.at(i) == 'S') {
      A = i;
    }
  }
  for (long long i = S.size() - 1; i >= 0; i--) {
    if (S.at(i) == 'T') {
      B = i;
    }
  }
  cout << A + (S.size() - 1 - B) + (B - A + 1) % 2 << endl;
}
