import Data.List
import Data.Array.Unboxed (Array, array, accumArray, (!), indices, elems, accum)

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!s)

memo :: Array Int [[Int]]
memo = foldl' dp (accumArray (++) [] (0,330) [(k,[[k]]) | k<-[0..9]]) [2..10]

dp :: Array Int [[Int]] -> Int -> Array Int [[Int]]
dp arr n = accum (++) arr (concatMap next [0..9])
 where
  next k = filter ((<=330).fst) $ zip ks' es'
   where
    ks' = map (+ (n*k)) (indices arr)
    es' = map (map (k:) . filter (\e -> length e == n-1 && notElem k e)) (elems arr)