#include <bits/stdc++.h>
int main(void) {
  char x[200000];
  scanf("%s", x);
  unsigned long len = strlen(x);
  int sgage = 0, tgage = 0;
  for (int i = 0; i <= strlen(x); i++) {
    if (x[i] == 'S' || i == strlen(x)) {
      if (tgage != 0) {
        len -= 2 * (tgage > sgage ? sgage : tgage);
        sgage = 0;
        tgage = 0;
      }
      sgage++;
    }
    if (x[i] == 'T') {
      tgage++;
    }
  }
  printf("%ld\n", len);
  return 0;
}
