#include <bits/stdc++.h>
using namespace std;
const int maxN = 200005;
char s[maxN];
int main(int argc, const char* argv[]) {
  scanf("%s", s);
  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 + 1, s + L + 1, s + i);
        L -= 2;
        change = true;
        ;
      }
    }
  }
  cout << L << endl;
  return 0;
}
