s=input() f = [0]*len(s) for i in range(len(s)-2): if s[i] == 'i' and s[i+1] == 'n' and s[i+2] == 'g': f[i] = 1 for i in range(len(s)-1): f[i+1] += f[i] ans = 0 for i in range(len(s)): if s[i] == 'S': ans += f[-1]-f[i] print(ans)