using System; using System.Collections.Generic; using System.Linq; static class Ponponpain { static void Main() { var s = Console.ReadLine(); var endIndex = s.IndexOf("pain"); if(endIndex <= 0 ) Console.WriteLine(-1); else { var pon = s.Substring(0, endIndex).Split('p').Where(x => x.StartsWith("on")).Count()-1; if(pon == 0) { Console.WriteLine(-1); } else { Console.WriteLine(pon); } } } }