#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  while (!s.empty() && s.back() == 'F') s.pop_back();
  reverse(s.begin(), s.end());
  vector<int> F, ats;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == 'F') F.push_back(i);
  if (F.empty()) return cout << 0, 0;
  ats.resize(F.size());
  for (int i = 0; i < F.size(); i++)
    ats[i] = i == 0 ? F[i] : max(ats[i - 1] + 1, F[i] - i);
  cout << ats.back();
}
