#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int MOD = 1000000007;
int main(int argc, char const* argv[]) {
  string x;
  cin >> x;
  while (x.find("ST") != string::npos) {
    x.erase(x.begin() + x.find("ST"), x.begin() + x.find("ST") + 2);
  }
  cout << x.size() << endl;
  return 0;
}
