readlines.each do |l|
  n,s = l.split.map(&:to_i)
  puts((0..9).to_a.combination(n).to_a.map do |c|
    c.permutation.count do |nums|
      nums.each_with_index.map{|m,i| m*(i+1)}.inject(:+) == s
    end
  end.inject(:+))
end