#include <bits/stdc++.h>
using namespace std;
int dx[]{1, -1, 0, 0, 1, -1, 1, -1};
int dy[]{0, 0, 1, -1, 1, -1, -1, 1};
long long suf(long long x) { return (x * (x + 1)) / 2; }
vector<vector<pair<long long, int> > > adj, wt;
const long long mod = 1e9 + 7, size = 1000006, oi = INT_MAX, ol = INT64_MAX;
int n, m, t, x, y;
int main(void) {
  string s;
  while (cin >> s) {
    int M = 0, F = 0, ans = 0, now = 0, bolz = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'F') {
        F++;
        ans = max(now + i - F + 1, ans);
        if (bolz) now++;
      } else
        now--, bolz = 1;
      now = max(now, 0);
    }
    cout << ans << endl;
  }
  return 0;
}
