#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
char s[N];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  int pt = 0, ss = 0;
  for (int i = 0; i < len && s[i] != 'S'; i++) pt++;
  for (int i = len - 1; i >= 0 && s[i] != 'T'; i--) ss++;
  if (!pt && !ss)
    printf("0\n");
  else
    printf("%d\n", pt + ss + abs(pt - ss));
  return 0;
}
