#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100008] = {0};
  int sj = 0, st = 0, ss = 0;
  scanf("%s", s);
  int i, j, k;
  for (i = 0; s[i] != 0; i++) {
    if (s[i] == 'S') ss++;
    if (s[i] == 'T') {
      if (st == 0 || ss == 0)
        st++;
      else {
        ss--;
      }
    }
  }
  printf("%d\n", ss + st);
  return 0;
}
