# -*- coding: utf-8 -*-


if __name__ == '__main__':
    n, m = map(int, input().split())
    C = [int(x) for x in input().split()]
    T = [float("inf") for _ in range(n+1)]
    T[0] = 0

    for i in range(m):
        for j in range(C[i], n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)

    print(T[n])
 if __name__ == '__main__':
    n, m = map(int, input().split())
    C = [int(x) for x in input().split()]
    T = [float("inf") for _ in range(n+1)]
    T[0] = 0

    for i in range(m):
        for j in range(C[i], n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)

    print(T[n]) __name__ == '__main__' __name__ '__main__' n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x C = [int(x) for x in input().split()] C [int(x) for x in input().split()] float("inf") for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) float("inf") float "inf" T = [float("inf") for _ in range(n+1)] T [float("inf") for _ in range(n+1)] T[0] = 0 T[0] T 0 0 for i in range(m):
        for j in range(C[i], n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)

     i range(m) range m for j in range(C[i], n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)

     j range(C[i], n+1) range C[i] C i n+1 n 1 T[j] = min(T[j], T[j - C[i]] + 1) T[j] T j min(T[j], T[j - C[i]] + 1) min T[j] T j T[j - C[i]] + 1 T[j - C[i]] T j - C[i] j C[i] C i 1 print(T[n]) print T[n] T n n, m = map(int, input().split()) map(int, input().split()) n C = [int(x) for x in input().split()] [int(x) for x in input().split()] C m = map(int, input().split()) map(int, input().split()) m T = [float("inf") for _ in range(n+1)] [float("inf") for _ in range(n+1)] T
# -*- coding: utf-8 -*-


if __name__ == '__main__':
    n, m = map(int, input().split())
    C = [int(x) for x in input().split()]
    T = [float("inf") for _ in range(n+1)]
    T[0] = 0

    for i in range(m):
        for j in range(C[i], n+1):
            T[j] = min(T[j], T[j - C[i]] + 1)

    print(T[n])

