#include <bits/stdc++.h>
int main(void) {
  int a, b, i, c;
  a = 0;
  b = 0;
  char s[200000];
  scanf("%s", &s);
  a = strlen(s);
  for (i = 0; i <= a; i++) {
    if (s[i] == 'S') {
      i++;
      if (s[i] == 'T') {
        b = b + 2;
      } else {
        i--;
      }
    }
  }
  c = a - b;
  printf("%d\n", c);
  return 0;
}
