#include <bits/stdc++.h>
using namespace std;
int n, a[1000001], Res;
string S;
void Case() {
  int Dem, Start, Top, Cho;
  Dem = 0;
  Top = 0;
  Cho = 0;
  Start = 1;
  while ((Start <= n) and (S[Start - 1] == 'F')) Start++;
  for (int i = Start; i <= n; i++)
    if (S[i - 1] == 'F') {
      Top++;
      a[Top] = Dem + Cho;
      Cho++;
    } else {
      Dem++;
      if (Cho > 0) Cho--;
    }
  Res = a[Top];
}
int main() {
  getline(cin, S);
  n = (int)S.size();
  Case();
  printf("%d", Res);
}
