#include <bits/stdc++.h>
using namespace std;
string op(string str) {
  auto pos = str.find("ST");
  if (pos == -1) {
    return str;
  }
  str.erase(pos, pos + 2);
  return str;
}
int main() {
  string str, st;
  cin >> str;
  for (;;) {
    st = op(str);
    if (st == str) break;
    str = st;
  }
  printf("%lu\n", st.length());
  return 0;
}
