require "prime"
primes = Prime.each(10000).to_a
arr = Hash.new(0)
0.upto(primes.length - 1){|i|
    sum = 0
    i.upto(primes.length - 1){|j|
        sum += primes[j]
        arr[sum] += 1
    }
}
while true
    x = gets.to_i
    break if x == 0
    puts arr[x]
end
