(defun memo (fn)
    (let ((table (make-hash-table :test 'equal)))
        #'(lambda (&rest rest)
              (multiple-value-bind (val found-p) (gethash rest table)
                  (if found-p
                      val
                      (setf (gethash rest table) (apply fn rest)))))))

(defun memoize (fn-name)
    (setf (symbol-function fn-name) (memo (symbol-function fn-name))))

(defmacro defun-memo (fn args &body body)
    `(memoize (defun ,fn ,args . ,body)))

(defun-memo rec (goal unuse-lst now)
    (cond ((eq goal now) 1)
        ((< goal now) 0)
        ((find now unuse-lst) 0)
        (t (+ (rec goal unuse-lst (+ 1 now))
               (rec goal unuse-lst (+ 2 now))))))

(defun solve (goal unuse-lst)
    (let ((result (rec goal unuse-lst 0)))
        (print result)))

(defun input ()
    (let ((goal (read))
             (num (read))
             (lst '()))
        (dotimes (i num)
            (push (read) lst))
        (solve n lst)))
