#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main(int argc, char** argv) {
  s2.push_back('S');
  s2.push_back('T');
  cin >> s1;
  int p;
  while ((p = s1.find(s2)) != string::npos) {
    s1.replace(p, 2, "");
  }
  cout << s1.size() << endl;
  return 0;
}
