#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int c1 = 0, c2 = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'T')
      c1++;
    else
      break;
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'S')
      c2++;
    else
      break;
  }
  printf("%d\n", max(c1, c2) * 2);
}
