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