#include <stdio.h>

int main()
{
	int primeTable[1300];
	int index = 0;
	for (int i = 2; i < 10000; i++)
	{
		for (int j = 0; j < index; j++)
		{
			if (i % primeTable[j] == 0)
				goto BREAK_1;
		}
		primeTable[index] = i;
		index++;
	BREAK_1:;
	}
	int start, end, pointer, tempSum, input, output;
	for (; (scanf("%d", &input)) && input != 0; printf("%d\n", output))
	{
		start = output = tempSum = end = 0;
		do
		{
			if (tempSum + primeTable[end] <= input)
			{
				tempSum += primeTable[end];
				if (tempSum == input)
					output++;
				end++;
			}
			else
			{
				tempSum -= primeTable[start];
				start++;
			}
		} while (start <= end);
	}
	return 0;
}
