import qualified Data.IntMap.Lazy as M

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

comb_of_numseq :: [Int] -> Int
comb_of_numseq [n,s]
 | s > 330 = 0
 | otherwise = length $ filter ((==n).length) (M.findWithDefault [] s memo)
 where memo = foldr (dp s) (M.fromList [(k,[[k]]) | k<-[0..9]]) [n,n-1..2]

dp :: Int -> Int -> M.IntMap [[Int]] -> M.IntMap [[Int]]
dp s n im = foldr (\i acc -> M.unionWith (++) acc (next i) ) M.empty [9,8..0]
 where next i = M.filterWithKey (\k _ -> k<=s) $ M.mapKeys (+ (n*i)) $ M.map (map (i:) . filter (notElem i)) im