#include <bits/stdc++.h>
int compare_ll(const void *a, const void *b) {
  return *(unsigned long long *)b - *(unsigned long long *)a;
}
int main(void) {
  unsigned long long len, Scnt, Tcnt, Tmax, i;
  char X[200001];
  Scnt = 0;
  Tcnt = 0;
  scanf("%s", &X);
  len = strlen(X);
  Tmax = len >> 1;
  for (i = 0; i < len; i++) {
    if (X[i] == 'T') {
      Tcnt++;
      if (Tcnt == Tmax) {
        break;
      }
    } else {
      Scnt++;
    }
  }
  printf("%lld\n", (Tcnt - Scnt) * 2);
  return 0;
}
