import Data.List

main = interact $ unlines . map (show . comb_of_numseq . map read . words) . lines

comb_of_numseq [n,s]
 | s > sum (zipWith ($) (reverse cf) [9,8..0]) = 0
 | s < sum (zipWith ($) cf [n-1,n-2..0]) = 0
 | otherwise = perms s cf [0..9]
 where
  cf = map (*) [1..n]
  perms 0 [] _ = 1
  perms 0 [f] cs = if elem 0 cs then 1 else 0
  perms _ [] _ = 0
  perms s' (f:fs) cs = sum' [perms s'' fs (delete c' cs) | c'<-cs, let s'' = s' - f c', s''>=0]
   where sum' xs = xs `seq` sum xs