#include <bits/stdc++.h>
using namespace std;
using IntType = long long;
int main() {
  string line;
  cin >> line;
  IntType len = line.length();
  IntType i, j;
  for (i = 0; line[i] == 'T' && i < len; i++)
    ;
  for (j = 0; line[len - 1 - j] == 'S' && j < len; j++)
    ;
  IntType k = max(i, j);
  cout << 2 * k << endl;
  ;
  int x = 3;
  ;
  return 0;
}
