import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- getc $ solve . split toInt
  mapM_ print xs

solve :: [Int] -> Int
solve [n,s] = (length . filter ((== s) . sum . zipWith ($) fs)) ks
  where
    f xs = [i:xs | i <- [0..9], i `notElem` xs]
    ks = (iterate (>>= f) [[]]) !! n
    fs = [(*i) | i <- [1..10]]
    
toInt :: String -> Int
toInt s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents