#include <bits/stdc++.h>
using namespace std;
template <class T>
void dbs(string str, T t) {
  cerr << str << " : " << t << "\n";
}
template <class T, class... S>
void dbs(string str, T t, S... s) {
  int idx = str.find(',');
  cerr << str.substr(0, idx) << " : " << t << ",";
  dbs(str.substr(idx + 1), s...);
}
const int N = (int)1e6 + 10;
char s[N];
int main() {
  scanf("%s", s);
  int prevT = -1, cntF = 0;
  int n = strlen(s);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'F') {
      int curT;
      if (i == cntF) {
        curT = 0;
      } else {
        curT = max(i - cntF, prevT + 1);
      }
      ans = max(ans, curT);
      prevT = curT;
      ++cntF;
    }
  }
  printf("%d\n", ans);
  return 0;
}
