#include <bits/stdc++.h>
char letter[200001];
int next[200000];
int num;
int start;
int end;
int sum;
bool flag = true;
int main() {
  scanf("%s", letter);
  for (int i = 0; i <= 200000; i++) {
    next[i] = i + 1;
    if (letter[i] == NULL) {
      num = i;
      break;
    }
  }
  sum = num;
  while (flag) {
    for (int i = 0; next[i] < num;) {
      if (letter[i] == 'S') {
        if (letter[next[i]] == 'T') {
          next[i - 1] = next[next[i]];
          sum -= 2;
          i = next[i];
          break;
        }
      }
      if (next[next[i]] >= num) {
        flag = false;
      }
      i = next[i];
    }
  }
  printf("%d\n", sum);
  return 0;
}
