#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int p = 0, f = 0, ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != 'F') {
      p = 0;
      continue;
    }
    ++f;
    ++p;
    if (f - 1 == i) continue;
    if (i - (f - 1) + (p - 1) > ans)
      ans = i - (f - 1) + (p - 1);
    else
      ans++;
  }
  cout << ans << endl;
  return 0;
}
