use std::process; fn getline() -> String{ let mut __ret=String::new(); std::io::stdin().read_line(&mut __ret).ok(); return __ret; } fn main(){ let s=getline(); let mut pain_index:i32 = -1; if s.len() < 4 { print!("{}", -1); process::exit(0); } for i in 0..s.len()-3 { if &s[i..i+4] == "pain" { pain_index = i as i32; break; } } if pain_index == -1 { print!("{}", -1); process::exit(0); } let mut pain_num:i32 = 0; for i in 0..(pain_index as usize) { if &s[i..i+3] == "pon" { pain_num = pain_num + 1; } } match pain_num { 0 => print!("{}", -1), 1 => print!("{}", -1), _ => print!("{}", pain_num -1), } }