http://codeforces.com/contest/353/problem/D
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 10000010
using namespace std; char str[maxn];
int main()
{
scanf("%s",str);
int k=strlen(str);
int ans=,t1=;
for(int i=; i<k; i++)
{
if(str[i]=='M') t1++;
else if(t1) ans=max(ans+,t1);
}
printf("%d\n",ans);
return ;
}