from bisect import bisect_left string = input() S_s = [] ing_s = [] for i in range(len(string)): if string[i] == "S": S_s.append(i) elif string[i:i+3] == "ing": ing_s.append(i) l = len(ing_s) ans = 0 for s in S_s: ans += l - bisect_left(ing_s, s) print(ans)