#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  vector<string> st = {"ST", "STST", "STSTST", "STSTSTST"};
  bool flag = false;
  while (1) {
    flag = false;
    if (X.find("ST") != string::npos) {
      for (int i = st.size() - 1; i >= 0; i--) {
        if (X.find(st[i]) != string::npos) {
          X.erase(X.find(st[i]), st[i].length());
          flag = true;
        }
      }
    }
    if (!flag) break;
  }
  cout << X.length() << endl;
}
