{-# OPTIONS_GHC -O3 -fexpose-all-unfoldings -fdicts-cheap -fdicts-cheap #-}
 
import Data.List
 
zipn xs = sum (zipWith (*) xs [1..])
 
nAndS [n ,s]
  | zipn [(10-n)..9] <  s = "0"
  | zipn [(10-n)..9] == s = "1"
  | zipn [0..(n-1)]  >  s = "0"
  | zipn [0..(n-1)]  == s = "1"
  | otherwise             = nAndS'[n ,s]
 
nAndS' :: [Int] -> String
nAndS' [n, s] = show $ length [xs | xs <- (perm [0..9] n)
                    ,zipn xs == s]
 
perm :: [Int] -> Int -> [[Int]]
perm xs n = [x:ys | x <- xs
                  , ys <- (if  (n > 1) then perm (delete x xs) (n - 1) else [[]])]
 
main = do
  s' <- getContents
  let s = map (map read) $ map words $ lines s'
  putStr $ unlines $ map nAndS s