#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const int N = 1000007;
int n, cnt, f[N], t[N];
char st[N];
int main() {
  gets(st);
  n = strlen(st);
  for (int i = 0; i < n; ++i)
    if (st[i] == 'F') f[cnt++] = i;
  t[0] = f[0];
  for (int i = 1; i < cnt; ++i) {
    if (f[i] == i)
      t[i] = 0;
    else
      t[i] = max(f[i] - i, t[i - 1] + 1);
  }
  if (cnt)
    printf("%d\n", t[cnt - 1]);
  else
    puts("0");
  return 0;
}
