s = read_line if i = s.index("pain") cnt = s[0...i].scan("pon").size puts cnt < 2 ? -1 : cnt - 1 else puts -1 end