#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5143;
const long long Linf = 1e18 + 5413;
const double eps = 1e-15;
const double pi = acos(-1);
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T lcm(T a, T b) {
  return a / __gcd(a, b) * b;
}
inline int read() {
  int res = 0LL;
  int neg;
  while (1) {
    char ch = getchar();
    if (ch >= '0' && ch <= '9' || ch == '-') {
      if (ch == '-')
        neg = -1;
      else
        neg = 1, res = ch - '0';
      break;
    }
  }
  while (1) {
    char ch = getchar();
    if (ch >= '0' && ch <= '9')
      res *= 10, res += ch - '0';
    else
      break;
  }
  return res * neg;
}
const int N = 1717171;
char s[N];
int main() {
  scanf(" %s", s + 1);
  int n = strlen(s + 1);
  int cntM = 0, delta = 0;
  int ans = 0;
  for (int(i) = (1); (i) <= (n); (i)++) {
    if (s[i] == 'F') {
      if (cntM > 0)
        umax(ans, cntM + delta);
      else {
        continue;
      }
      ++delta;
    } else {
      cntM++;
      --delta;
      if (delta < 0) delta = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
