#include <bits/stdc++.h>
using namespace std;
string str;
int main(void) {
  cin >> str;
  while (str.find("ST") != string::npos) str.erase(str.find("ST"), 2);
  cout << str.length() << endl;
  return 0;
}
