#include <iostream>
#include <vector>

int main(){
  int input;
  int n_data = 0;
  int max = 0;
  std::vector<int> data;
  std::vector<int> ans;
  while(std::cin >> input){
    if(input == 0) break;
    data.push_back(input);
    if(max < input){
      max = input;
    }
    n_data++;
  }
  int n = max;
  std::vector<int> prime;
  std::vector<bool> is_prime(n+1, true);
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<=n; ++i) {
    if(is_prime[i]) {
      prime.push_back(i);
      for(int j=2*i; j<=n; j+=i) {
        is_prime[j] = false;
      }
    }
  }

  for(int i=0; i<n_data; i++){
    int count = 0;
    for(int j=0; j<prime.size(); j++){
      for(int k=j+1; k<prime.size(); k++){
        if(prime[j]+prime[k] == data[i]){
          count++;
          break;
        }
      }
    }
    ans.push_back(count);
  }
  for(int i=0; i<ans.size(); i++){
    std::cout << ans[i] << std::endl;
  }
  return 0;
}