import Data.List
main :: IO ()
main = do
  [maxVal] <- getInts
  [numOfNonZero] <- getInts
  print $ length $ search numOfNonZero [1..maxVal]

search :: Int -> [Int] -> [Int]
search numOfNonZero = filter $ hasNonZeroIs numOfNonZero

hasNonZeroIs :: Int -> Int -> Bool
hasNonZeroIs nonZeroNum num = (numOfNonZero == nonZeroNum)
  where
    numOfNonZero = foldl (\s n -> if n /= '0' then s + 1 else s) 0 $ show num 

getInts = do
  x <- getLine
  let y = (map $ read) $ words x :: [Int]
  return y
