S = input() h, ans= 0, 0 for i in range(len(S)-2): if S[i] == "S": h += 1 if S[i] == "i" and S[i+1] == "n" and S[i+2] == "g": ans += h print(ans)