#include <bits/stdc++.h>
using namespace std;
char s[210000], stk[210000], top;
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    while (top < 0) top++;
    if (top && stk[top] == 'S' && s[i] == 'T') {
      top--;
      continue;
    } else {
      stk[++top] = s[i];
    }
  }
  printf("%d\n", top);
}
