#include <bits/stdc++.h>
using namespace std;
bool SR(int &_x) { return scanf("%d", &_x) == 1; }
bool SR(long long &_x) { return scanf("%lld", &_x) == 1; }
bool SR(double &_x) { return scanf("%lf", &_x) == 1; }
bool SR(char *_s) { return scanf("%s", _s) == 1; }
bool RI() { return true; }
template <typename I, typename... T>
bool RI(I &_x, T &..._tail) {
  return SR(_x) && RI(_tail...);
}
void SP(const int _x) { printf("%d", _x); }
void SP(const long long _x) { printf("%lld", _x); }
void SP(const double _x) { printf("%.16lf", _x); }
void SP(const char *s) { printf("%s", s); }
void PL() { puts(""); }
template <typename I, typename... T>
void PL(const I _x, const T... _tail) {
  SP(_x);
  if (sizeof...(_tail)) putchar(' ');
  PL(_tail...);
}
const int maxn = 1e6 + 6;
char in[maxn];
void read() { RI(in); }
deque<char> q;
void build() {
  q = deque<char>(in, in + strlen(in));
  while (((int)(q).size()) && q[0] == 'F') q.pop_front();
}
void sol() {
  int prv = 0, cur = 0, cnt = 0;
  for (int i = 0; i < int(((int)(q).size())); i++)
    if (q[i] == 'F') {
      swap(prv, cur);
      cur = max(prv + 1, i - (cnt++));
    }
  PL(cur);
}
int main() {
  read();
  build();
  sol();
  return 0;
}
