import Data.List

nAndS :: [Int] -> String
nAndS [n, s] = show $ length [xs | xs <- (perm [0..9] n)
                    ,sum (zipWith (*) xs [1..]) == s]

perm :: Eq a => [a] -> Int -> [[a]]
perm [] _ = [[]]
perm _ 0  = []
perm xs 1 = [[x]| x <- xs]
perm xs n = concat [map (x:) (perm(delete x xs) (n-1)) | x <- xs]

main = do
  s' <- getContents
  let s = map (map read) $ map words $ lines s'
  putStr $ unlines $ map nAndS s