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