S = input() counts = 0 counti = 0 for i in range(len(S)-3,-1,-1): if S[i:i+3] == 'ing': counti += 1 if S[i] == "S": counts += counti print(counts)