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 = length $ filter (== s) [sum (zipWith ($) cf cs) | cs <- (permutation' n [0..9])]
 where cf = map (*) [1..n]

permutation' :: Int -> [a] -> [[a]]
permutation' 0 _  = [[]]
permutation' n xs =
  [y:zs | (y, ys) <- select xs, zs <- permutation' (n - 1) ys]

select :: [a] -> [(a, [a])]
select [x] = [(x, [])]
select (x:xs) = (x,xs) : [(y, x:ys) | (y, ys) <- select xs]