#include <bits/stdc++.h>
using namespace std;
char s1[200005];
char s2[2] = {'S', 'T'};
int main() {
  int i, num;
  scanf("%s", s1);
  while (strstr(s1, s2)) {
    i = 0;
    num = strlen(s1);
    char *p = strstr(s1, s2);
    int cnt = strlen(p);
    while (i != strlen(s2)) {
      *p++ = '\0';
      i++;
    }
    strcpy(s1 + (num - cnt), p);
  }
  num = strlen(s1);
  cout << num << endl;
  return 0;
}
