object Main extends App {
    def s(n: Int): List[Int] = {
        if(n % 2 == 0) 2 :: s(n/2)
        else if(n % 5 == 0) 5 :: s(n/5)
        else Nil
    }
    val in = io.Source.stdin.getLines.map(_.toInt).toList.init
    in.foreach{n => val p = (2 to n).flatMap(s).partition(_ == 2); println(p._1.size min p._2.size)}
}