s = read_line i = s.index("pain") if i && i >= 3 s = s[0...i] c = 0.upto(s.size - 3).count { |p| s[p..(p + 2)] == "pon" } puts c >= 2 ? c - 1 : -1 else puts -1 end