#include <bits/stdc++.h>
int l = 0;
char* ss(char* a) {
  int p = 0, op = 0;
  static char o[200001];
  while (p < strlen(a)) {
    if (p + 1 != strlen(a)) {
      if (a[p] != 'S' || a[p + 1] != 'T') {
        o[op] = a[p];
        op++;
      } else {
        l++;
        p++;
      }
    } else {
      o[op] = a[p];
      op++;
    }
    p++;
  }
  o[op] = '\0';
  return o;
}
int main() {
  int lk = 0;
  char str[200001];
  scanf("%s", &str);
  while (1) {
    strcpy(str, ss(str));
    if (lk == l) break;
    lk = l;
  }
  printf("%d\n", strlen(str));
  return 0;
}
