#include <bits/stdc++.h>
char x[200005];
int main(void) {
  char input;
  int i = 0;
  while (1) {
    scanf("%c", &input);
    if (input == '\n') {
      x[i] = '\0';
      break;
    }
    x[i] = input;
    if (input == 'T') {
      if (i > 0 && x[i - 1] == 'S') {
        i -= 2;
      }
    }
    i++;
  }
  printf("%d\n", strlen(x));
  return 0;
}
