#include <bits/stdc++.h>
int main() {
  char *src = new char[200000];
  char *rst = new char[200000];
  scanf("%s", src);
  int src_len = strlen(src);
  int i(0), j(0);
  bool find = false;
  while (true) {
    if (src[i] == 'S' && src[i + 1] == 'T') {
      find = true;
      i = i + 2;
    } else {
      rst[j] = src[i];
      i = i + 1;
      j = j + 1;
    }
    if (i == src_len) {
      rst[j] = '\0';
      if (find == false)
        break;
      else {
        i = j = 0;
        memcpy(src, rst, strlen(rst) + 1);
        src_len = strlen(src);
        find = false;
        if (src_len == 0) break;
      }
    } else
      continue;
  }
  printf("%d\n", strlen(rst));
  delete[] src;
  delete[] rst;
  return 0;
}
