object Main extends App {
  def primeNumbers(stream: Stream[Int] = Stream.iterate(2)(_ + 1),n: Int = 2): Stream[Int] ={
    val newStream = stream.filter(_ % n != 0)
    n #:: primeNumbers(newStream, newStream.head)
  }
  Stream.continually(readLine).takeWhile(_ != null).map(_.toInt)
    .map(n => if (n == 1) 0 else primeNumbers().takeWhile(_ <= n).size)
    .foreach(println)
}

