$sumhash = {}

### subroutines

def check_sum(n, s, used = 0)
  key = "#{n},#{s},#{used}"
  return $sumhash[key] if ! $sumhash[key].nil?

  if n == 0
    return s == 0 ? 1 : 0
  end

  count = 0

  for i in (0..9)
    b = 1 << i
    ni = n * i
    if (used & b) == 0 && s >= ni
      used |= b
      count += check_sum(n - 1, s - ni, used)
      used ^= b
    end
  end

  return $sumhash[key] = count
end

### main

while (line = gets)
  n, s = line.chomp.split(" ").map{|s| s.to_i}

  puts check_sum(n, s)
end