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

for i in range(2, 101):

    if primes[i]:

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

            primes[j] = 0

while True:

    n = int(eval(input()))

    if n == 0:

        break

    m = n

    while not primes[m]:

        m -= 1

    pnum = [i for i in range(m+1) if primes[i]]

    ans = 0

    for i in range(len(pnum)):

        tmp = 0

        for j in range(i, len(pnum)):

            tmp += pnum[j]

            if tmp == n:

                ans += 1

                break

            if tmp > n:

                break

    print(ans)
primes = [0, 0] + [1]*9999

for i in range(2, 101):

    if primes[i]:

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

            primes[j] = 0

pnums = [i for i in range(10001) if primes[i]]

while True:

    n = int(eval(input()))

    if n == 0:

        break

    m = n

    while not primes[m]:

        m -= 1

    ans = 0

    end = pnums.index(m)+1

    for i in range(end):

        tmp = 0

        for j in range(i, end):

            tmp += pnums[j]

            if tmp == n:

                ans += 1

                break

            if tmp > n:

                break

    print(ans)
primes = [0, 0] + [1] * 9999
for i in range(2, 101):
    if primes[i]:
        for j in range(i * i, 10001, i):
            primes[j] = 0
while True:
    n = int(eval(input()))
    if n == 0:
        break
    m = n
    while not primes[m]:
        m -= 1
    pnum = [i for i in range(m + 1) if primes[i]]
    ans = 0
    for i in range(len(pnum)):
        tmp = 0
        for j in range(i, len(pnum)):
            tmp += pnum[j]
            if tmp == n:
                ans += 1
                break
            if tmp > n:
                break
    print(ans)

primes = [0, 0] + [1] * 9999
for i in range(2, 101):
    if primes[i]:
        for j in range(i * i, 10001, i):
            primes[j] = 0
pnums = [i for i in range(10001) if primes[i]]
while True:
    n = int(eval(input()))
    if n == 0:
        break
    m = n
    while not primes[m]:
        m -= 1
    ans = 0
    end = pnums.index(m) + 1
    for i in range(end):
        tmp = 0
        for j in range(i, end):
            tmp += pnums[j]
            if tmp == n:
                ans += 1
                break
            if tmp > n:
                break
    print(ans)

+pnums = [i for i in range(10001) if primes[i]] -    pnum = [i for i in range(m + 1) if primes[i]] -    for i in range(len(pnum)): +    end = pnums.index(m) + 1 +    for i in range(end): -        for j in range(i, len(pnum)): -            tmp += pnum[j] +        for j in range(i, end): +            tmp += pnums[j]