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