using System; public class Hello { static void Main() { var s = Console.ReadLine().Trim(); getAns(s); } static void getAns(string s) { var p = s.IndexOf("pain"); if (p == -1) { Console.WriteLine(-1); return; } var t = s.Substring(0, p); var tL = t.Length; var ans = (tL - t.Replace("pon", "").Length) / 3 - 1; Console.WriteLine(ans); } }