while line = gets
  n = line.to_i
  n_sqrt = Math.sqrt(n).floor
  numbers = [*2..n]
  primes = []

  while num = numbers.shift
    primes << num

    break if num > n_sqrt

    numbers.delete_if { |number| number % num == 0 }
  end

  primes << numbers
  puts primes.length
end