$arr = Array.new(1_000_000)

def save(n, b)
  $arr[n] = n
  b
end

def prime?(n)
  return $arr[n] unless $arr[n].nil?
  return save(n, true) if n == 2
  return save(n, false) if n.even?
  l = Math.sqrt(n)
  3.upto(l) { |i| return save(n, false) if (n % i).zero? }
  save(n, true)
end

while line = gets
  n = line.to_i
  count = n >= 2 ? 1 : 0
  3.step(n, 2).each do |i|
    count += 1 if prime?(i)
  end
  p count
end

