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