#include <bits/stdc++.h>
using namespace std;
vector<char> smaller(string s, int n) {
  vector<char> smallersize;
  int flag = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'F' && flag == 0) {
      continue;
    } else {
      smallersize.push_back(s[i]);
      flag = 1;
    }
  }
  return smallersize;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  vector<char> v = smaller(s, n);
  int gno = 0;
  int prevans = 0;
  int maxtime = 0;
  int time = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == 'F') {
      if (i - gno > prevans) {
        time = i - gno;
      } else {
        time = prevans + 1;
      }
      gno++;
      maxtime = max(maxtime, time);
      prevans = time;
    }
  }
  cout << maxtime << endl;
  return 0;
}
