#include <bits/stdc++.h>
using namespace std;
const int maxN = 200005;
char s[maxN];
int main(int argc, const char* argv[]) {
  while (scanf("%s", s) != EOF) {
    int L = int(strlen(s));
    bool change = true;
    while (change) {
      change = false;
      for (int i = 0; i < L - 1; i++) {
        if (s[i] == 'S' && s[i + 1] == 'T') {
          copy(s + i + 2, s + L + 1, s + i);
          L -= 2;
          change = true;
          break;
        }
      }
    }
    printf("%d\n", L);
  }
  return 0;
}
