import re s=input() s=re.sub(r'S','0',s) s=re.sub(r'ing','1',s) s=re.sub(r'[a-zA-Z]','',s) l=list(map(int,list(s))) c=0 for i in range(len(l)): if l[i]<1: c+=sum(l[i+1:]) print(c)