#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int res = 0, cntall = 0, pause = 0, i = 0, respause = 0;
  while (i < s.size() && s[i] == 'F') i++;
  cntall = i;
  res = i - 1;
  for (; i < s.size(); i++) {
    if (s[i] == 'F') {
      if (res < i) res = i, respause = pause;
      pause++;
      cntall++;
    } else {
      pause = max(0, pause - 1);
    }
  }
  cout << res - cntall + 1 + respause;
  return 0;
}
