import Data.List
import Data.IntMap.Lazy (IntMap, (!), fromList, insertWith, keys, elems)

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) (memo `seq` (memo!s))

memo :: IntMap [[Int]]
memo = foldl' dp (fromList [(k,[[k]]) | k<-[0..9]]) [2..10]

dp :: IntMap [[Int]] -> Int -> IntMap [[Int]]
dp im n = foldl' (\acc (k,v) -> insertWith (++) k v acc) im (concatMap next [0..9])
 where
  next k = filter ((<=330).fst) (zip ks' es')
   where
    ks' = map (+ (n*k)) (keys im)
    es' = map (map (k:) . filter (\v -> length v == n-1 && notElem k v)) (elems im)