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