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