#include <stdio.h>

int main(){
  int scount = 0; int c; int count = 0;
  while((c = getchar()) != EOF) {
    if(c == 'S') {
    	scount++;
    } else if(c == 'T') {
      if(scount > 0) scount--;
      else count++;
    }
  }
  printf("%d\n", count + scount);
  return 0;
}