#include <bits/stdc++.h>
using namespace std;
int ss[1000008] = {0};
int main() {
  char s[1000008] = {0};
  int i, j, x, n, r = 0, p;
  scanf("%s", s);
  for (i = 0, j = 0; s[i] != 0; i++) {
    if (s[i] == 'S') {
      ss[j] = i;
      j++;
    }
  }
  while (777) {
    r = 0;
    for (p = 0; ss[p] != 0; p++) {
      int k = ss[p];
      for (j = k + 1;; j++) {
        if (s[j] == 0) goto pp;
        if (s[j] == '0') continue;
        if (s[j] == 'T') break;
        if (s[j] == 'S') goto pp;
      }
      s[k] = '0';
      s[j] = '0';
      r++;
    pp:;
    }
    if (!r) break;
  }
  r = 0;
  for (i = 0; s[i] != 0; i++)
    if (s[i] != '0') r++;
  printf("%d\n", r);
  return 0;
}
