cf D. Queue
http://codeforces.com/contest/353/problem/D
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define maxn 10000010 5 using namespace std; 6 7 char str[maxn]; 8 int main() 9 { 10 scanf("%s",str); 11 int k=strlen(str); 12 int ans=0,t1=0; 13 for(int i=0; i<k; i++) 14 { 15 if(str[i]=='M') t1++; 16 else if(t1) ans=max(ans+1,t1); 17 } 18 printf("%d\n",ans); 19 return 0; 20 }