#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int INF = 1e9;
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 << 2 * (s.size() - 1 - i) << endl;
      return 0;
    }
  }
}
