#include <bits/stdc++.h>
int min(int a, int b) {
  if (a < b) {
    return (a);
  } else {
    return (b);
  }
}
int main(void) {
  char x[200020];
  scanf("%s", x);
  int counts = 0, countt = 0;
  bool s;
  for (int i = 0; i < strlen(x); i++) {
    if (x[i] == 'T' && s == true) {
      countt++;
    }
    if (x[i] == 'S') {
      s = true;
      counts++;
    }
  }
  for (int i = 1; i <= strlen(x); i++) {
    if (x[strlen(x) - i] == 'T') {
      break;
    } else {
      counts--;
    }
  }
  printf("%lu\n", strlen(x) - 2 * min(counts, countt));
  return 0;
}
