#include <bits/stdc++.h>
int main() {
  int i = 0, count, z = 0;
  char s[222222];
  scanf("%s", s);
  while (1) {
    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++;
      z = 0;
    } else if (strlen(s) == 0)
      break;
    else {
      z++;
      if (count > 0) {
        count = 0;
        i = 0;
      }
      if (strlen(s) == z)
        break;
      else
        ++i;
    }
  }
  printf("%d\n", strlen(s));
  return 0;
}
