#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int inf = 1e7;
const int MAXM = 1e5 + 5;
const int MAXN = 1e6 + 4;
vector<int> v;
int dp[MAXN];
int main() {
  int i, j, k, n;
  string s;
  cin >> s;
  n = s.length();
  for (i = 0; i < n; i++) {
    if (s[i] == 'F') v.push_back(i);
  }
  for (i = 0; i < v.size(); i++) {
    if (v[i] == i)
      dp[i] = 0;
    else
      dp[i] = max(v[i] - i, dp[i - 1] + 1);
  }
  cout << dp[(int)v.size() - 1] << endl;
  return 0;
}
