using System.Collections.Generic; using System; public class Hello { static void Main() { var s = Console.ReadLine().Trim(); if (s.Length < 4) Console.WriteLine(0); else getAns(s); } static void getAns(string s) { var ans = 0L; var ping = searchING(s); var ps = seachS(s); foreach (var x in ping) ans += ps[x - 1]; Console.WriteLine(ans); } static int[] seachS(string s) { var sL = s.Length; var res = new int[sL]; res[0] = s[0] == 'S' ? 1 : 0; for (int i = 1; i < sL; i++) res[i] = s[i] == 'S' ? res[i - 1] + 1 : res[i - 1]; return res; } static List searchING(string s) { var res = new List(); var sL = s.Length; var p = 0; while (p < sL) { var p2 = s.IndexOf("ing", p); if (p2 != -1) res.Add(p2); else break; p = p2 + 3; } return res; } }