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