import Data.Char (digitToInt)

f :: [Int] -> Int -> Bool -> Int
f _ 0 _ = 1
f [] _ _ = 0
f (s:ss) k less
  | less = f ss k True + 9 * f ss (k - 1) True
  | s > 0 = f ss k True + (s - 1) * f ss (k - 1) True + f ss (k - 1) False
  | otherwise = f ss k False

main = do
    s <- map digitToInt <$> getLine :: IO [Int]
    k <- readLn :: IO Int
    print $ f s k False
