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