#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  string::size_type pos = s.rfind("ST");
  while (pos != string::npos) {
    s.erase(pos, 2);
    pos = s.rfind("ST");
  }
  cout << s.length() << endl;
  return 0;
}
