let s = stdin.ReadLine () let mutable pon_count = 0 for i in 0..s.Length-1 do if s.[i..i+3] = "pain" then printfn "%d" (if pon_count < 2 then -1 else pon_count - 1) exit 0 elif s.[i..i+2] = "pon" then pon_count <- pon_count + 1 printfn "-1"