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