#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long LINF = 1LL << 62;
int main() {
  string s;
  cin >> s;
  while (s.find("ST") != string::npos) {
    auto p = s.find("ST");
    s.erase(p, 2);
  }
  cout << s.length() << endl;
  return 0;
}
