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