# s = '' # len = (1..(100)).to_a.sample # len.times do # s << [?p, ?h, ?n, ?o, ?m, ?e].sample # end # puts s # puts len s = gets.chomp ans = 0 while true f = false t = s.gsub("phnom", "penh") f |= s != t ans += s.size - t.size u = t.gsub("h", "").gsub("e", "h") f |= t != u break unless f ans += 1 s = u end puts ans