while s=gets do
  n=s.to_i
  upto=Math.sqrt(n).to_i
  pr=Array.new(n,true)
  for i in 2..upto do
    if pr[i]
      j=2
      while i*j<=n do
        pr[i*j]=false
        j+=1
      end
    end
  end
  count=0
  for i in 1..n/2 do
    if pr[i]&&pr[n-i-3]&&n-i-3!=i
      count+=1
    end
  end
  puts count
end