#include <bits/stdc++.h>
using namespace std;
char s[205];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  int ss = 0, st = 0, sum = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] == 'S')
      ss++;
    else if (s[i] == 'T' && ss)
      st++;
    if (st == ss) sum += ss * 2, ss = 0, st = 0;
  }
  printf("%d\n", len - sum);
}
