#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  while (1) {
    auto n = s.rfind("ST");
    if (n == string::npos) break;
    s.erase(n, 2);
  }
  cout << s.size() << endl;
  return 0;
}
