#include <bits/stdc++.h>
using namespace std;
int ss[200008] = {0};
int main() {
  char s[200008] = {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;
      j++;
    }
  }
  int ll = j;
  while (777) {
    r = 0;
    int p = 0;
    for (i = ss[p]; p < ll; p++) {
      i = ss[p];
      int f = 1;
      if (s[i] == 'S') {
        int k = i;
        for (j = i + 1;; j++) {
          if (s[j] == 0) {
            f = 0;
            break;
          }
          if (s[j] == '0') continue;
          if (s[j] == 'T') break;
          if (s[j] == 'S') {
            f = 0;
            break;
          }
        }
        if (f) {
          s[k] = '0';
          s[j] = '0';
          r++;
        }
      }
    }
    if (!r) break;
  }
  r = 0;
  for (i = 0; s[i] != 0; i++)
    if (s[i] != '0') r++;
  printf("%d\n", r);
  return 0;
}
