#include <stdio.h>

#define N 10000

static int k_operafan[ N + 1 ];
static int p[ N + 1 ] = { 1, 1, 0 };
static int pn;

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( i = 2; i * i <= N; ++i )
  {
    if ( p[ i ] ) continue ;

    for ( j = i * i; j <= N; j += i )
    {
      p[ j ] = 1;
    }
  }
  for ( i = 2; i <= N; ++i )
  {
    if ( p[ i ] ) continue ;

    p[ pn++ ] = i;
  }
  for ( i = 0; i < pn; ++i )
  {
    int s = 0;

    for ( j = i; j < pn; ++j )
    {
      s += p[ j ];
      if ( s > N ) break ;

      ++k_operafan[ s ];
    }
  }

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    printf ( "%d\n", k_operafan[ n ] );
  }

  return ( 0 );
}