import bisect

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 iter(input,'0'):x=int(x);print((sum(a[x-d]>0 for d in p[:bisect.bisect(p,x//2)])))

import bisect

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 iter(input,'0'):x=int(x);print((sum(1 for d in p[:bisect.bisect(p,x//2)]if a[x-d])))

import bisect
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 iter(input, "0"):
    x = int(x)
    print((sum(a[x - d] > 0 for d in p[: bisect.bisect(p, x // 2)])))

import bisect
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 iter(input, "0"):
    x = int(x)
    print((sum(1 for d in p[: bisect.bisect(p, x // 2)] if a[x - d])))

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