#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  while (1) {
    int OS = S.length();
    for (int i = 0; i < S.length() - 1; i++) {
      if (S.at(i) == 'S' && S.at(i + 1) == 'T') {
        S = S.erase(i, 2);
      }
    }
    if (S == "") {
      cout << 0 << endl;
      return 0;
    }
    if (S.length() == OS) {
      cout << S.length() << endl;
      return 0;
    }
  }
  return 0;
}
