#include <bits/stdc++.h>
using namespace std;
int main() {
  int length = 0;
  char input;
  char a[200020];
  a[0] = 'Q';
  while (scanf("%c", &input) != EOF) {
    if (input == 'T' && a[length] == 'S') {
      length--;
    } else {
      length++;
      a[length] = input;
    }
  }
  printf("%d\n", length);
  return 0;
}
