#include <bits/stdc++.h>
int main() {
  int a;
  char b[200001];
  int s;
  int t;
  for (int i = 0; i < 200001; i++) {
    b[i] == 0;
  }
  scanf("%s", b);
  a = strlen(b);
  if (b[0] == 83) t = 1;
  for (int i = 1; i < a; i++) {
    if (b[i] == 83) {
      if (b[i - 1] == 83)
        t++;
      else
        t = 1;
    } else {
      if (t > 0) {
        t--;
        s++;
      }
    }
  }
  printf("%d\n", a - (2 * s));
  return 0;
}
