import Data.List
 
main = interact $ unlines . map (show . comb_of_numseq . map read . words) . lines
 
comb_of_numseq [n,s] = perms s [1..n] [0..9]

perms 0 [] _ = 1
perms _ [] _ = 0
perms s' aas@(a:as) ccs@(c:cs)
 | s' > sum (zipWith (*) (reverse aas) (reverse ccs)) = 0
 | s' < sum (zipWith (*) aas ccs') = 0
 | otherwise = sum [perms (s'-a*c') as (delete c' ccs) | c'<-ccs]
 where ccs' = if c==0 then reverse (take (length as) cs) else reverse (take (length aas) ccs)