require 'prime'

### constant

MAX_N = 1120
MAX_K = 14

### subroutines

def count_rec(n, k, pi)
  return $cache[n][k][pi] if $cache[n][k][pi]

  count = 0

  for i in (pi...$np)
    pni = $pnums[i]
    break if n < pni

    count += count_rec(n - pni, k - 1, i + 1)
  end

  $cache[n][k][pi] = count 
end

### main

$pnums = Prime.each(MAX_N).to_a
$np = $pnums.length
#p $pnums
#p $np

loop do
  n, k = gets.split.map(&:to_i)
  break if (n | k) == 0

  $cache = (n + 1).times.map{(k + 1).times.map{$np.times.map{nil}}}
  for n0 in (0..n)
    for pi in (0..$np)
      $cache[n0][1][pi] = 0
    end
  end

  for i in (0...$np)
    pni = $pnums[i]
    break if pni > n
    for j in (0..i)
      $cache[pni][1][j] = 1
    end
  end

  count = count_rec(n, k, 0)
  puts count
end