import bisect,sys

from itertools import *

n=list(range(50001));a=list(n);a[1]=0

for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])

p=list(compress(n,a))

for x in sys.stdin:

 x=int(x)

 if x:print((sum(1 for d in p[:bisect.bisect(p,x//2)]if a[x-d])))

import bisect,sys

from itertools import *

n=list(range(50001));a=list(n);a[1]=0

for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])

p=list(compress(n,a))

for x in map(int,sys.stdin):

 if x:print((len([1 for d in p[:bisect.bisect(p,x//2)]if a[x-d]])))

import bisect, sys
from itertools import *

n = list(range(50001))
a = list(n)
a[1] = 0
for i in range(2, 224):
    a[i * 2 :: i] = [0] * len(a[i * 2 :: i])
p = list(compress(n, a))
for x in sys.stdin:
    x = int(x)
    if x:
        print((sum(1 for d in p[: bisect.bisect(p, x // 2)] if a[x - d])))

import bisect, sys
from itertools import *

n = list(range(50001))
a = list(n)
a[1] = 0
for i in range(2, 224):
    a[i * 2 :: i] = [0] * len(a[i * 2 :: i])
p = list(compress(n, a))
for x in map(int, sys.stdin):
    if x:
        print((len([1 for d in p[: bisect.bisect(p, x // 2)] if a[x - d]])))

-for x in sys.stdin: -    x = int(x) +for x in map(int, sys.stdin): -        print((sum(1 for d in p[: bisect.bisect(p, x // 2)] if a[x - d]))) +        print((len([1 for d in p[: bisect.bisect(p, x // 2)] if a[x - d]])))