#include <bits/stdc++.h>
int main() {
  int i, len;
  char string[200000];
  int sum = 0;
  int result = 0;
  scanf("%s", string);
  len = strlen(string);
  while (i < len) {
    if (string[i] == 'S') {
      result = 1;
    } else if (string[i] == 'T') {
      result = -1;
    }
    if (result < 0) {
      sum += (-1 * result);
      result = 0;
    }
    i++;
  }
  printf("%d", sum + result);
}
