#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  for (auto itr = X.begin(); itr != X.end() - 1;) {
    if ((*itr == 'S') && (*(itr + 1) == 'T')) {
      X.erase(itr, itr + 2);
      if (X.size() == 0) {
        break;
      }
      itr = X.begin();
    } else {
      itr++;
    }
  }
  cout << X.size() << endl;
  return 0;
}
