#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int lcm(int x, int y) { return x * y / gcd(x, y); }
string in;
int check(string s) {
  int ret = 0;
  while (true) {
    bool beforem = s[0] == 'M';
    bool changed = false;
    for (int i = 1; i < s.size(); ++i) {
      if (s[i] == 'F') {
        if (beforem) {
          s[i - 1] = 'F';
          s[i] = 'M';
          changed = true;
        }
        beforem = false;
      } else {
        beforem = true;
      }
    }
    if (!changed) break;
    ++ret;
  }
  return ret;
}
int main() {
  cin >> in;
  vector<int> times;
  int fcnt = 0;
  for (int i = 0; i < in.size(); ++i) {
    if (in[i] == 'F') {
      if (times.size() == 0) {
        if (i == fcnt) {
          times.push_back(0);
        } else {
          times.push_back(i);
        }
      } else {
        if (i == fcnt) {
          times.push_back(0);
        } else {
          int move = i - fcnt;
          if (times[times.size() - 1] + 1 <= move) {
            times.push_back(move);
          } else {
            times.push_back(times[times.size() - 1] + 1);
          }
        }
      }
      ++fcnt;
    }
  }
  int ret = 0;
  for (int i = 0; i < times.size(); ++i) ret = max(ret, times[i]);
  printf("%d", ret);
  return 0;
}
