#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cerr.tie(0), cout.tie(0);
  cout.precision(10);
  cout << fixed;
  string s;
  cin >> s;
  long long n = s.size();
  long long wait = 0;
  long long i = 0;
  long long t = 0, brr = 0;
  while (i < n && s[i] == 'F') i++;
  for (; i < n; i++) {
    if (s[i] == 'F') {
      t = brr + wait;
      wait++;
    } else {
      wait--;
      brr++;
    }
    wait = max(0LL, wait);
  }
  cout << t;
  return 0;
}
