#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  cin >> s;
  while (true) {
    if (s.size() == 0) break;
    long long it = s.find("ST");
    if (it == -1) break;
    s = s.substr(0, it) + s.substr(it + 2);
  }
  cout << s.size() << endl;
  return 0;
}
