#include <bits/stdc++.h>
using namespace std;
namespace {}
int main() {
  string X;
  cin >> X;
  while (true) {
    string::size_type index = X.find("ST");
    if (index == string::npos) {
      break;
    }
    string leftS("");
    string rightS("");
    if (index >= 1) {
      leftS = X.substr(0, index);
    }
    if (index <= X.size() - 3) {
      rightS = X.substr(index + 2);
    } else {
      rightS = X.substr(index);
    }
    X = leftS + rightS;
  }
  cout << X.size() << endl;
  return 0;
}
