n=int(input()) s=input() ans=0 for i in range(n): if s[i]!='M': continue j=1 while j<=i and i+j