import bisect

primes = [0, 0] + [1] * 49999

for i in range(2, 225):

    if primes[i]:

        for j in range(i*i, 50001, i):

            primes[j] = 0

values = [i for i, k in enumerate(primes) if k]

while True:

    n = int(eval(input()))

    if n == 0:

        break

    I = bisect.bisect(values, n//2)

    print((sum(primes[n-v] for v in values[:I])))
import bisect

primes = [0, 0] + [1] * 49999

for i in range(2, 225):

    if primes[i]:

        for j in range(i*i, 50001, i):

            primes[j] = 0

values = [i for i, k in enumerate(primes) if k]

while True:

    n = int(eval(input()))

    if n == 0:

        break

    I = bisect.bisect(values, n//2)

    print((sum(1 for v in values[:I] if primes[n-v])))
import bisect

primes = [0, 0] + [1] * 49999
for i in range(2, 225):
    if primes[i]:
        for j in range(i * i, 50001, i):
            primes[j] = 0
values = [i for i, k in enumerate(primes) if k]
while True:
    n = int(eval(input()))
    if n == 0:
        break
    I = bisect.bisect(values, n // 2)
    print((sum(primes[n - v] for v in values[:I])))

import bisect

primes = [0, 0] + [1] * 49999
for i in range(2, 225):
    if primes[i]:
        for j in range(i * i, 50001, i):
            primes[j] = 0
values = [i for i, k in enumerate(primes) if k]
while True:
    n = int(eval(input()))
    if n == 0:
        break
    I = bisect.bisect(values, n // 2)
    print((sum(1 for v in values[:I] if primes[n - v])))

-    print((sum(primes[n - v] for v in values[:I]))) +    print((sum(1 for v in values[:I] if primes[n - v])))