#include <bits/stdc++.h>
int main() {
  char s[200001];
  int len;
  int loop;
  int flag;
  int i;
  scanf("%s", s);
  do {
    len = strlen(s);
    for (loop = 0, flag = 0; flag == 0 && loop < len; loop++) {
      if (s[loop] == 'S' && s[loop + 1] == 'T') {
        for (i = loop; i < len - 1; i++) s[i] = s[i + 2];
        flag = 1;
      }
    }
  } while (loop < len);
  printf("%d\n", len);
  return 0;
}
