#include <bits/stdc++.h>
int sub(char *ch);
int main(void) {
  char x[200002];
  int h = 1, i, j, a, b, c;
  scanf("%s", x);
  a = sub(x);
  while (h != 0) {
    h = 0;
    for (i = 0; i < a; i++) {
      if (x[i] == 'S' && x[i + 1] == 'T') {
        b = sub(x);
        for (j = i; j < b; j++) {
          if (j + 2 < b) {
            x[j] = x[j + 2];
          } else {
            x[j] = '\0';
          }
        }
        h++;
      }
    }
  }
  a = sub(x);
  printf("%d\n", a);
  return 0;
}
int sub(char *ch) {
  int ca = 0;
  while (ch[ca] != '\0') ca++;
  return ca;
}
