#include <bits/stdc++.h>
using namespace std;
long long actioncnt;
string removestring(string s, string target) {
  actioncnt = 0;
  for (long long i = 0; i <= s.size() - target.size(); i++) {
    if (i > s.size() - target.size()) break;
    if (s.substr(i, target.size()) == target) {
      if (s.size() == target.size()) {
        return "";
      }
      s.erase(i, target.size());
      actioncnt++;
    }
  }
  return s;
}
signed main() {
  string s;
  cin >> s;
  while (1) {
    s = removestring(s, "ST");
    if (s == "") break;
    if (actioncnt == 0) break;
  }
  cout << s.size() << endl;
  return 0;
}
