def solve(ary, n, s)
  hash = ary.map {|i| [11, 13, 17, 19, 23, 29, 31, 37, 41, 43][i]}.inject(&:*)
  hash *= n
  return @memo[[hash, s]] if @memo.has_key?([hash, s])
  co = 0
  ary.each do |i|
    s1 = s - i * n
    if n == 1
      if s1.zero?
        co += 1
      end
    elsif s1 > 0
      co += solve(ary - [i], n - 1, s1)
    end
  end
  @memo[[hash, s]] = co
end

$<.readlines.map {|a| a.split.map(&:to_i)}.each do |n, s|
  puts solve([*0..9], n, s)
end
