#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  cin >> s;
  long long ans = 0;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'T')
      ans++;
    else
      break;
  }
  long long tmp = 0;
  for (long long i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'S')
      tmp++;
    else
      break;
  }
  ans = max(ans, tmp);
  cout << 2 * ans << endl;
}
