#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  bool f = 0;
  long last = -1, c = 0;
  long ans = 0;
  for (register int i = 0; i < s.length(); i++) {
    if (s[i] == 'F') {
      if (last == -1) {
        last = i;
      } else {
        last = max(i - c, (last == 0) ? 0 : last + 1);
      }
      ans = max(ans, last);
      c++;
    }
  }
  cout << ans << endl;
  return 0;
}
