import java.util.ArrayList;
import java.util.Scanner;
public class qq001 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int n;
ArrayList<Integer> prime=primes(1000);
// System.out.println(prime);
while(in.hasNext()){
n = in.nextInt();
System.out.println(countPrimeSum(prime,n));
}
}
private static int countPrimeSum(ArrayList<Integer> prime,int n){
int i=0;
int j=prime.size() - 1;
int count = 0;
while(i<=j){
int t = prime.get(i) + prime.get(j);
if(t==n){
// System.out.println(prime.get(i)+" "+prime.get(j));
count++;
i++;
j--;
}else if(t<n){
i++;
}else{
j--;
}
}
return count;
}
private static ArrayList<Integer> primes(int n){
ArrayList<Integer> prime = new ArrayList<Integer>();
prime.add(2);
prime.add(3);
for(int i=4;i<=n;i++){
boolean flag = true;
for(int j=0;j<prime.size();j++){
if(i%prime.get(j) == 0){
flag = false;
break;
}
}
if(flag){
prime.add(i);
}
}
return prime;
}
}