#include <bits/stdc++.h>
using namespace std;
string s;
bool Solve() {
  string now;
  int i;
  bool ok = 0;
  for (i = 0; i < (int)s.size() - 1; ++i) {
    if (s[i] == 'S' && s[i + 1] == 'T') {
      ++i;
      ok = 1;
      continue;
    }
    now += s[i];
  }
  if (i == s.size() - 1) now += s[s.size() - 1];
  s = now;
  return ok;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  while (Solve())
    ;
  cout << s.size() << '\n';
  return 0;
}
