#include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int di[][2] = {{1, 0}, {0, 1},  {-1, 0}, {0, -1},
                     {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
string op(const string str) {
  string ret = str;
  auto pos = str.find("ST");
  if (pos == -1) {
    return str;
  }
  ret = str.substr(0, pos) + str.substr(pos + 2, str.length());
  return ret;
}
int main() {
  string str, st;
  cin >> str;
  for (;;) {
    st = op(str);
    if (st == str) break;
    str = st;
  }
  cout << st.length() << endl;
  return 0;
}
