Numbers = [0,1,2,3,4,5,6,7,8,9]
Used = []

def solve(coefficient, n, s)
  if n == 0 && s == 0 then
    return 1
  elsif n == 0 || s < 0 then
    return 0
  else
    c = 0
    (0..9).each{|i|
      next if Used.index(i) != nil
      Used.push(i)
      c += solve(coefficient + 1, n - 1, s - coefficient * i)
      Used.pop
    }
    return c
  end
end

loop do
  v = $stdin.gets.split(" ").map{|n| n.to_i}
  break if v[0] == 0
  p solve(1, v[0], v[1])
end