import scala.io.Source.stdin

object Main extends App {
  stdin.getLines.foreach { s =>
    val n = s.split(" ").map(_.toInt)
    println {
      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
    }
  }
}