(defparameter N (read))
(defparameter K (read))

(defun check (num)
  (let ((s (princ-to-string num)))
       (loop for i from 0 below (length s)
             if (not (equal #\0 (aref s i)))
             count i)))

(defun count-num (n-num k-num)
  (loop for i from 1 to n-num
        if (= k-num (check i))
        count i))

(format t "~A" (count-num N K))