#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  string::iterator last_t = x.begin();
  for (auto i = (x).begin(); i != (x).end(); i++) {
    if (*i == 'T') {
      last_t = next(i);
    }
  }
  int num_t = 0, num_s = 0;
  for (string::iterator i = x.begin(); i != last_t; ++i) {
    if (*i == 'T') {
      ++num_t;
    } else {
      ++num_s;
    }
  }
  if (num_s <= 0) {
    cout << 0 << endl;
  } else {
    cout << x.size() - 2 * min(num_s, num_t) << endl;
  }
  return 0;
}
