#include <bits/stdc++.h>
const int N = 2e6 + 1;
char a[N];
char temp[N];
int main(void) {
  scanf("%s", a);
  char b[2] = {'S', 'T'};
  char *p;
  while ((p = strstr(a, b)) != NULL) {
    *p = '\0';
    strcpy(temp, p + strlen(b));
    strcat(a, temp);
  }
  long long ans = strlen(a);
  printf("%lld\n", ans);
  return 0;
}
