#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 50;
const int mod = 1e9 + 7;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
string s;
bool vis[N];
int main() {
  cin >> s;
  int len = s.length();
  int ans = 0, sum = 0, cnt = 0;
  bool flag = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] == 'F') {
      if (flag) cnt++;
      ans = sum + cnt - flag;
    } else
      sum++, cnt = max(cnt - 1, 0), flag = 1;
  }
  cout << ans;
}
