#include <bits/stdc++.h>
int main() {
  char s[200005];
  scanf("%s", s);
  int i;
  for (i = 0; s[i] != '\0'; i++)
    ;
  int j, h;
  int k;
  for (k = 0; k <= 100; k++) {
    for (j = 0; (s[j] != 'S' || s[j + 1] != 'T') && j <= i - 1; j++)
      ;
    if (j >= i - 1) {
    } else {
      for (h = j; h <= i - 1; h++) {
        s[h] = s[h + 2];
      }
      i = i - 2;
      s[i] = '\0';
    }
  }
  int l;
  for (l = 0; s[l] != '\0'; l++)
    ;
  printf("%d", l);
  return 0;
}
