#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
const long long inf = 1e18L + 5;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long testcases = 1;
  while (testcases--) {
    string s;
    cin >> s;
    long long x = 0, ans = 0, f = 0;
    for (long long i = 0; i < s.length(); ++i) {
      if (s[i] == 'F') {
        if (i > f) {
          ans = i - f + x;
          x++;
        }
        f++;
      } else {
        x--;
        x = max(x, 0ll);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
