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