NUMS = (0..9).to_a

readlines.each do |line|
  n, s = line.chomp.split.map(&:to_i)

  count = 0
  NUMS.permutation(n).each do |nums|
    result = [nums, (1..n).to_a].transpose.map { |_n|
      _n.inject(&:*)
    }.inject(&:+)

    count += 1 if result == s
  end

  puts count
end