#include <bits/stdc++.h>
using namespace std;
long long int n, key, ans, a;
int main() {
  string s;
  cin >> s;
  n = s.size();
  key = n / 2;
  for (int i = 0; i < n; i++) {
    if (key == 0) {
      break;
    }
    if (s[i] == 'T') {
      key--;
    }
    ans++;
  }
  cout << 2 * (n - ans);
  return 0;
}
