#include <bits/stdc++.h>
int C;
char p[101000];
int main() {
  int i, c = 0, r = 0;
  scanf("%s", p);
  for (i = 0; p[i]; i++) {
    r++;
    if (p[i] == 'S')
      c++;
    else {
      if (c) {
        r -= 2;
        c--;
      }
    }
  }
  printf("%d\n", r);
}
