#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
vector<long long int> v1;
vector<long long int> v2;
const long long int inf = 100000000000005;
long long int hs[1000005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long int co = 0, t = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'F')
      hs[i] = co;
    else {
      hs[i] = 0;
      co++;
    }
  }
  for (int i = 0; i < s.length(); i++) {
    if (hs[i] == 0) continue;
    if (hs[i] - t > 0)
      t += (hs[i] - t);
    else if ((hs[i] - t) <= 0)
      t++;
  }
  cout << t << endl;
  return 0;
}
