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