#include <bits/stdc++.h>
char s[200001], b[200001];
int ls, lb;
int T;
int main(void) {
  scanf("%s", s);
  while (s[++ls])
    ;
  int i = 0;
  while (i < ls) {
    char k = s[i++];
    if (k == 'S') {
      b[lb++] = 'S';
    } else if (s[lb - 1] == 'S')
      lb--;
    else
      b[lb++] = 'T';
  }
  printf("%d", lb);
  return 0;
}
