#include <bits/stdc++.h>
using namespace std;
string s;
const int MAXN = 1100000;
long long pos[MAXN], ans, num[MAXN], coun, cnt, dp[MAXN], M[MAXN], t[MAXN];
int main() {
  cin >> s;
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == 'F') {
      pos[++cnt] = i;
      num[i] = cnt;
      M[cnt] = coun;
    } else
      ++coun;
  }
  dp[1] = M[1];
  t[1] = 0;
  ans = dp[1];
  for (int i = 2; i <= cnt; i++) {
    if (M[i - 1] > 0) {
      t[i] = max(0ll, t[i - 1] - (pos[i] - pos[i - 1] - 1) + 1);
      dp[i] = t[i] + M[i];
    } else {
      t[i] = 0ll;
      dp[i] = M[i];
    }
    ans = max(ans, dp[i]);
  }
  cout << ans;
  return 0;
}
