def calc(arr,n,s)
  return if s > @s || arr.map{|i| i*@n}.inject(:+) < @s || n > @n
  if n==@n && s==@s
    @cnt += 1
    return
  end
  arr.each do |i|
    calc(arr.reject{|j| i==j},n+1,s+i*(n+1))
  end
end

readlines.each do |l|
  @cnt = 0
  @n,@s = l.split.map(&:to_i)
  calc((0..9).to_a, 0, 0)
  puts @cnt
end