#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string X;
  cin >> X;
  int i, count;
  while ((i = X.find("ST")) != string::npos) {
    X.erase(X.begin() + i);
    X.erase(X.begin() + i);
  }
  cout << X.length() << endl;
  return 0;
}
