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