#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int main() {
  string s;
  cin >> s;
  int c = 0;
  for (; s[c] == 'T'; c++)
    ;
  int d = 0;
  for (; s[s.size() - d - 1] == 'S'; d++)
    ;
  cout << max(c, d) * 2 << endl;
  return 0;
}
