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