import Data.List
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 = foldl' dp (M.fromList [(k,[[k]]) | k<-[0..9]]) [2..n]

dp :: M.IntMap [[Int]] -> Int -> M.IntMap [[Int]]
dp im n = foldl' (\acc i -> M.unionWith (++) acc (next i) ) M.empty [0..9]
 where next i = M.filterWithKey (\k _ -> k<=330) $ M.mapKeys (+ (n*i)) $ M.map (map (i:) . filter (\v -> length v == (n-1) && notElem i v)) im