#include <bits/stdc++.h>
int main(void) {
  char x[200001];
  scanf("%s", x);
  int len = strlen(x), flag = 0;
  while (flag == 0) {
    flag = 1;
    for (int i = 0; i < len; i++) {
      int start = i, end;
      while (x[start] == 'y') {
        start++;
      }
      end = start + 1;
      while (x[end] == 'y') {
        end++;
      }
      if (x[start] == 'S' && x[end] == 'T') {
        x[start] = 'y';
        x[end] = 'y';
        flag = 0;
      }
    }
  }
  int count = 0;
  for (int i = 0; i < len; i++) {
    if (x[i] == 'y') {
      count++;
    }
  }
  printf("%d\n", len - count);
  return 0;
}
