import Data.List
 
main = interact $ unlines . map (show . comb_of_numseq . map read . words) . lines
 
comb_of_numseq [n,s] = length $ filter (==s) $ candidate n s

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