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