#include <bits/stdc++.h>
int main(void) {
  int i, len = 0, count = 0, count2 = 0;
  char ch[200000];
  scanf("%s", ch);
  for (i = 0; (ch[i] != '\0'); i++) {
    len++;
  }
  for (i = 0; i < len; i++) {
    if (ch[i] == 'S') {
      count++;
      if ((ch[i + 1] == 'T')) {
        count2 += count;
        count = 0;
      }
    }
  }
  printf("%d\n", (len - (count2 * 2)));
  return 0;
}
