#include <bits/stdc++.h>
int main() {
  int check = 1;
  int j;
  char a[200001];
  int i = 0;
  int sum = 0;
  scanf("%s", a);
  while (check != 0) {
    if (a[i] == '\0') check = 0;
    if (a[i] == 'S' && a[i + 1] == 'T') {
      for (j = i; j <= 200000; j++) {
        a[j] = a[j + 2];
        if (a[j] == '\0') {
          j = 200001;
        }
      }
      i = 0;
    } else
      i++;
  }
  for (i = 0; a[i] != '\0'; i++) {
    sum = sum + 1;
  }
  printf("%d", sum);
}
