#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(9);
  string S;
  cin >> S;
  int tmp = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != 'T') break;
    tmp++;
  }
  int ans = tmp;
  tmp = 0;
  for (int i = S.size() - 1; i >= 0; i--) {
    if (S[i] != 'S') break;
    tmp++;
  }
  cout << max(ans, tmp) * 2 << endl;
  return 0;
}
