def check_sum(n, s, used = (0..9).map{false})
  if n == 0
    return s == 0 ? 1 : 0
  end

  count = 0

  for i in (0..9)
    ni = n * i
    if ! used[i] && s >= ni
      used[i] = true
      count += check_sum(n - 1, s - ni, used)
      used[i] = false
    end
  end

  return count
end

### main

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

  puts check_sum(n, s)
end