def prime_list num
  @cache ||= []
  return [] if num == 1
  return @cache[num] if @cache[num]
  result = prime_list(num - 1)
  if result.inject(true) { |n, j| n && (num%j != 0) }
    result << num
  end
  return @cache[num] = result
end

while line = gets do
  puts prime_list(line.to_i).length
end