#include <bits/stdc++.h>
using namespace std;
long long int n, a, t;
string s;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  long long int male = 0;
  long long int ans = 0;
  for (long long int i = 0; i < (long long int)s.length(); i++) {
    if (s[i] == 'F' && male)
      ans = max(ans + 1, male);
    else if (s[i] == 'M')
      male++;
  }
  cout << ans << '\n';
}
