#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int ret = 0;
  bool flg = false;
  int num = 0;
L1:
  for (int i = 0; i < X.size() - 1 && X.size() > 0; i++) {
    if (X[i] == 'S' && X[i + 1] == 'T') {
      X.erase(i, 2);
      goto L1;
    }
  }
  cout << X.size() << endl;
  return 0;
}
