#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'T') cnt++;
    if (cnt == s.size() / 2) {
      cout << (s.size() - i - 1) * 2 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}
