#include <bits/stdc++.h>
unsigned int min(unsigned int a, unsigned int b) { return a < b ? a : b; }
void TF_print(char boolean, char T[], char F[]) {
  if (boolean) {
    printf("%s\n", T);
  } else {
    printf("%s\n", F);
  }
}
int main() {
  char S[200000];
  scanf("%s", S);
  unsigned int len = strlen(S);
  unsigned int i, s = 0, save = 0, t = 0, count = 0;
  for (i = 0; i < len; ++i) {
    if (S[i] == 'S') {
      if (s == 0) {
        count += min(save, t) * 2;
        t = 0;
      }
      s++;
    } else {
      if (t == 0) {
        save = s;
        s = 0;
      }
      t++;
    }
  }
  count += min(save, t) * 2;
  printf("%u\n", len - count);
  return 0;
}
