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