#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000002;
char a[maxn];
int n, m, s, ans;
int main() {
  int i;
  scanf("%s", a);
  n = strlen(a);
  for (i = 0; i < n; ++i)
    if (a[i] == 'F') {
      if (m) {
        ans = max(ans, m + s);
        ++s;
      }
    } else {
      ++m;
      if (s) --s;
    }
  printf("%d\n", ans);
  return 0;
}
