#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(0);
  string s;
  cin >> s;
  while (s.find("ST") != string::npos) {
    s = s.substr(0, s.find("ST")) + s.substr(s.find("ST") + 2);
  }
  cout << (s).size();
  return 0;
}
