#include <bits/stdc++.h>
char *strremove(char *str, const char *sub) {
  size_t len = strlen(sub);
  if (len > 0) {
    char *p = str;
    while ((p = strstr(p, sub)) != NULL) {
      memmove(p, p + len, strlen(p + len) + 1);
    }
  }
  return str;
}
int main() {
  int i, len;
  char string[200000];
  char result[200000];
  scanf("%s", string);
  len = strlen(string);
  i = 0;
  while (i < len) {
    strcpy(result, strremove(string, "ST"));
    i++;
  }
  printf("%d", (int)strlen(result));
  return 0;
}
