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