#include <bits/stdc++.h>
char a[200005];
char b[5] = {"ST"};
int main() {
  scanf("%s", a);
  char *p;
  char c[81];
  while ((p = strstr(a, b)) != NULL) {
    *p = '\0';
    strcpy(c, p + strlen(b));
    strcat(a, c);
  }
  printf("%d", strlen(a));
  return 0;
}
