#include <bits/stdc++.h>
using namespace std;
bool str_replace(string &s, const string &search, const string replace) {
  bool rem = false;
  for (size_t pos = 0;; pos += replace.size()) {
    pos = s.find(search, pos);
    if (pos == string::npos) break;
    s.erase(pos, search.size());
    rem = true;
    s.insert(pos, replace);
  }
  return rem;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  while (str_replace(s, "ST", ""))
    ;
  cout << s.size() << endl;
}
