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