#include <bits/stdc++.h>
using namespace std;
string st;
int ll, gss, pd;
int main() {
  cin >> st;
  ll = st.size() - 1;
  for (int i = 0; i < ll; i++) {
    if (st[i] == 'S') pd = 1;
    if (st[i] == 'T' && pd == 1) {
      gss += 2, pd = 0;
    }
  }
  cout << ll + 1 - gss << endl;
  return 0;
}
