#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int sar = 0;
  int numf = -1;
  vector<int> v;
  long long ans = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == 'F')
      numf++;
    else
      continue;
    int he = i - numf;
    if (he == 0) continue;
    while (sar != (int)v.size() && v[sar] < he) sar++;
    ans = (int)v.size() - sar + he;
    v.push_back(ans);
  }
  cout << ans;
  return 0;
}
