#include <bits/stdc++.h>
int main(void) {
  char* x;
  int counter = 0;
  int ans = 0;
  scanf("%s", x);
  while (*x) {
    if (*x == 'T') {
      if (counter == 0) {
        ans++;
      }
      counter = ((0) > (counter - 1) ? (0) : (counter - 1));
    } else {
      counter++;
    }
    x++;
  }
  printf("%d\n", ans + counter);
  return 0;
}
