#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  getline(cin, s);
  long long k = s.find("ST");
  while (k != -1) {
    s.erase(k, 2);
    k = s.find("ST");
  }
  cout << s.size() << endl;
  return 0;
}
