#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, n;
  string st;
  cin >> st;
  k = st.find("ST");
  while (k >= 0) {
    st.replace(k, 2, "");
    k = st.find("ST");
  }
  cout << st.length() << endl;
  return 0;
}
