def count(limit, max, n, queue)
  return queue.inject(:+) == max ? 1 : 0 if queue.size == limit

  (n..9).step.inject(0) do |result, i|
    result += count(limit, max, i + 1, queue << i)
    queue.pop
    result
  end
end

def bfs
  while gets
    limit, max = $_.split.map(&:to_i)
    break if limit == 0 && max == 0
    puts count(limit, max, 0, [])
  end
end

bfs