import scala.io.Source.stdin

object Main {
  val max = new Array[Int](10)
  val min = new Array[Int](10)
  for(i <- 0 to 9) {
    var k = 1
    for(j <- 0 to i) {
        max(i) += (9-j)*k
        min(i) += j*k
        k += 1
    }
  }

  def main(args:Array[String]) = {
    val result = stdin.getLines.map { s=>
      val n = s.split(" ").map(_.toInt)
      if(max(n(0)-1)<n(1) || min(n(0)-1) > n(1)) 0
      else if(max(n(0)-1)==n(1)) 1
      else {
        List(0,1,2,3,4,5,6,7,8,9).combinations(n(0)).map { p =>
          p.permutations.count( l => (1 to n(0)).map(i => i*l(i-1)).sum == n(1) )
        }.sum
      }
    }
    println(result.mkString("\n"))
  }
}