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