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