text: #include <cmath>
  #include <cctype>
  #include <cstdio>
  #include <cstring>
  #include <set>
  #include <map>
  #include <stack>
  #include <queue>
  #include <string>
  #include <vector>
  #include <numeric>
  #include <iomanip>
  #include <iostream>
  #include <algorithm>
  #define fn "task"
  #define ll long long
  #define int long long
  #define pc(x) putchar(x)
  #define fileIn freopen("testdata.in", "r", stdin)
  #define fileOut freopen("testdata.out", "w", stdout)
  #define rep(i, a, b) for (int i = (a); i <= (b); ++i)
  #define per(i, a, b) for (int i = (a); i >= (b); --i)
  #ifdef yyfLocal
  #define dbg(x) std::clog << #x" = " << (x) << std::endl
  #define logs(x) std::clog << (x) << std::endl
  #else
  #define dbg(x) 42
  #define logs(x) 42
  #endif
  
  int read() {
      int res = 0, flag = 1; char ch = getchar();
      while (!isdigit(ch)) { if (ch == ';-';) flag = -1; ch = getchar(); }
      while (isdigit(ch)) res = res * 10 + ch - 48, ch = getchar();
      return res * flag;
  }
  
  void print(int x) {
      if (x < 0) putchar(';-';), x = -x;
      if (x > 9) print(x / 10);
      putchar(x % 10 + 48);
  }
  
  const int N = 10000 + 5;
  int n;
  std::vector<int> primes;
  
  bool isp(int x) { if (x <= 1) return false; for (int i = 2; i * i <= x; ++i) if ((x % i) == 0) return false; return true; }
  void init() { rep(i, 2, N) if (isp(i)) primes.push_back(i); }
  
  void solution() {
      int ans = (primes[0] == n), sum = primes[0], head = 0, tail = 1;
      while (head < primes.size() && tail < primes.size()) {
          sum += primes[tail++]; 
          while (sum > n) sum -= primes[head++];
          ans += (sum == n);
      }
      print(ans), puts("");
  }
  
  signed main() {
  #ifdef yyfLocal
      fileIn;
      fileOut;
  #else  
  #ifndef ONLINE_JUDGE   
      freopen(fn".in", "r", stdin);
      freopen(fn".out", "w", stdout);
  #endif
  #endif
      logs("main.exe");
      init();
      while (std::cin >> n && n) solution();
  }