def binary_search(l, r, arr, val)
  if l == r then
    return l
  else
    m = (l + r)/2
    if val == arr[m] then
      return m + 1
    elsif val < arr[m] then
      return binary_search(l, m,arr, val)
    else
      return binary_search(m+1, r,arr, val)
    end
  end
end

MAX = 999999
sqrt_max = Math.sqrt(MAX).ceil

prime = [2]
arr = Array.new(MAX){nil}
i = 3
while i <= MAX
  arr[i] = i
  i += 2
end

0.upto(sqrt_max){|i|
  next unless arr[i]
  prime << arr[i]
  j = it = arr[i]
  while j <= MAX
    arr[j] = nil
    j += it*2
  end
}
prime += arr.compact!

while n = gets
  #binary search
  puts binary_search(0, prime.size, prime, n.to_i)
end