// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();
    
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();

  for(var i = 0, len = input.length-1; i < len; i++){
    var target = +input[i];

    var result = 0;
    for(var j = 1; primeNumbers[j] < target; j++){
      var thisPrimeNums = primeNumbers[j];
      var search = target - thisPrimeNums;
      for(var k = 1; primeNumbers[k] <= search && primeNumbers[k] <= thisPrimeNums ; k++){
        if(primeNumbers[k] == search)
          result += 1;
      }
    }

    console.log(result);
    
  }
     
}
   
function calcPrimeNumbers(){
  var max = 50021;
  var primeNumbers = new Int8Array(max + 1);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
  var primeNums = new Int32Array(5134 + 1);
  var c = 0;
  for(var i = 1; i <= max; i++){
    if(!primeNumbers[i]){
      primeNums[++c] = i;
    }
  }
     
  return primeNums;
}