chars = gets.chomp.gsub("-","").chars m = false i = false n = false count = 0 chars.length.times do |j| if chars[j] == "m" m = true elsif chars[j] == "i" and m i = true elsif chars[j] == "n" and (chars[j + 1] == "m" or chars[j + 1].nil?) and m and i n = true else m = false i = false n = false end if m and i and n count += 1 m = false i = false n = false end end puts count