#include <bits/stdc++.h>
using namespace std;
int n;
char ent[1000100];
int main() {
  scanf("%s", ent);
  int n = strlen(ent);
  int pqp = 0, resp = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (ent[i] == 'F')
      pqp++;
    else if (pqp)
      resp = max(resp + 1, pqp);
  }
  printf("%d\n", resp);
  return 0;
}
