#include <bits/stdc++.h>
int main() {
  char x[200];
  scanf("%s", x);
  unsigned char len = 0;
  unsigned char newlen = 0;
  unsigned char n = 0;
  len = strlen(x);
  newlen = len;
  while (n < len / 2) {
    unsigned char i = 0;
    unsigned char j = 0;
    for (i = 0; i < newlen; i++) {
      if (x[i] == 'S' && x[i + 1] == 'T') {
        for (j = i; j < newlen - 1; j++) {
          x[j] = x[j + 2];
        }
        newlen = newlen - 2;
      }
    }
    n++;
  }
  printf("%u", newlen);
  return 0;
}
