#include <bits/stdc++.h>
const int MAXN = 2E3 + 10;
char s[MAXN];
int que[MAXN], tail;
int main() {
  scanf("%s", s);
  for (int i = 0; s[i]; ++i)
    if (s[i] == 'T' && tail >= 0 && que[tail] == 'S')
      --tail;
    else
      que[++tail] = s[i];
  printf("%d\n", tail);
  return 0;
}
