include Math

def check_prime(num)
  j = 3
  while j <= num / 2
    if(num % j == 0)
      return false
    else
      j += 2
    end
  end
  return true
end
while line = gets do
  n,other =  line.split.map(&:to_i)
  i = n + 1
  count = 0
  if(n == 0)
    break
  end
  if(i == 2)
    count += 1
  end
  if(i % 2 == 0)
    i += 1
  end
  while i <= n * 2
    if check_prime(i)
      count += 1
    end
    i += 2
  end
  puts count

end