#include <stdio.h>

int main( void ) {

	int prime[10000], i, j, n, sum, count;

	for ( i = 0; i < 10000; i++ ) { prime[i] = 1; }
	prime[0] = 0;
	
	for ( i = 0; i < 10000; i++ ) {
		
		if ( prime[i] == 1 ) {

			for ( j = i + 1; j < 10000; j++ ) {
			
				if ( ( j + 1 ) % ( i + 1 ) == 0 ) { prime[j] = 0; }
		
			}

		}

	}

	while ( scanf( "%d", &n ) && n > 0 ) {

		count = 0;

		for ( i = 0; i < n; i++ ) {

			sum = 0;

			if ( prime[i] == 1 ) {
				
				for ( j = i; j < n; j++ ) {

					if ( prime[j] == 1 ) {

						sum += j + 1;

						if ( sum == n ) { count++; }
						else if ( sum > n) { break; }

					}

				}

			}

		}

		printf( "%d\n", count );

	}

	return 0;

}