S=input().replace("ing","#") c=0 ans=0 for i in range(len(S)): if S[i]=="#": ans+=c if S[i]=="S": c+=1 print(ans)