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