class Integers
  def initialize
    @num = 0
    @results = []
    while val = $stdin.gets do
      n, sum = val.chomp.split(' ').map(&:to_i)
      if n == 0 && sum == 0 
        break
      end
      calc(n,sum)
    end

    @results.each do |s|
      puts s
    end
  end

  def calc(n, sum)
    ans = []
    (("1"+"0"*n).to_i-1).times do |val|
      arr = ("%0#{n}d" % val).split('').map(&:to_i)
      if arr.inject(:+) == sum
        if digit_check(arr) && !ans.include?(arr.sort)
          ans << arr.sort
        end
      end
    end
    @results << ans.size
  end

  def digit_check(arr)
    0.upto(9) do |n|
      return false if arr.count(n) > 1
    end
    return true
  end
end

i = Integers.new