S = gets.chomp ans = 0 stack = [] pon_cnt = 0 S.each_char do |s| stack << s if s == 'n' && stack.size >= 3 pon_cnt += 1 if stack[-3] == 'p' && stack[-2] == 'o' if stack.size >= 4 && stack[-4] == 'p' && stack[-3] == 'a' && stack[-2] == 'i' if pon_cnt >= 2 puts pon_cnt - 1 else puts -1 end exit end end end puts -1