#include <bits/stdc++.h>
using namespace std;
int main() {
  string input;
  int steps = 0;
  cin >> input;
  int i = 0;
  while (input[i] == 'F') i++;
  int dest = i, diff, prevt = 0;
  for (; i < input.size(); i++) {
    if (input[i] == 'F') {
      diff = i - dest;
      if (diff <= prevt)
        prevt = prevt + 1;
      else
        prevt = diff;
      steps = max(steps, prevt);
      dest++;
    }
  }
  cout << steps;
  return 0;
}
