#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j = 0, k = -1, n, m, asn;
  string s;
  cin >> s;
  n = s.size();
  for (m = 0; m < n && s[m] == 'F'; m++)
    ;
  for (i = m; i < n; i++)
    if (s[i] == 'F') {
      k = max(k + 2, i);
      j++;
    }
  cout << max(0, k - j - m + 1) << endl;
  return 0;
}
