#include <bits/stdc++.h>
char s[222222];
char st[222222], top;
int main() {
  scanf("%s", s);
  top = 0;
  for (int i = 0; s[i]; i++)
    if (top > 0 && s[i] == 'T' && st[top - 1] == 'S')
      --top;
    else
      st[top++] = s[i];
  printf("%d\n", top);
  return 0;
}
