#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 2e15;
const double PI = acos(-1);
map<long long, int> prime_factor(long long n) {
  map<long long, int> res;
  for (int i = 2; i < sqrt(n) + 1; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) ++res[n];
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'T') ++cnt;
    if (cnt == n / 2) {
      ans = n - (i + 1 - n / 2) * 2;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
