object Main { import java.util.regex._ val minPat = Pattern.compile("mi-*n") def countAllMatches (pat:Pattern) (str:String) = { val m = pat.matcher(str) @scala.annotation.tailrec def loop (idx:Int) (result:Int) :Int = { if (!m.find(idx)) { result }else{ val nextIdx = m.end() val nextResult = result + 1 loop (nextIdx) (nextResult) } } loop (0) (0) } def main(args: Array[String]): Unit = { val str = readLine() println(countAllMatches (minPat) (str)) } }