#include <bits/stdc++.h>
const int N = 200000;
int del, len, l, r;
char s[N + 5];
int main() {
  scanf("%s", s + 1);
  len = strlen(s + 1);
  l = 1;
  r = 2;
  while (r <= len) {
    if (s[l] == 'S' && s[r] == 'T')
      del += 2, l--, r++;
    else
      l = r, r++;
  }
  printf("%d\n", len - del);
  return 0;
}
