import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    C = list(map(int, input().split()))

    dp = [f_inf] * (n + 1)
    dp[0] = 0
    for c in C:
        for i in range(1, n + 1):
            if i - c >= 0:
                dp[i] = min(dp[i], dp[i - c] + 1)
    print(dp[-1])


if __name__ == '__main__':
    resolve()
 import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline f_inf = float('inf') f_inf float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def resolve():
    n, m = map(int, input().split())
    C = list(map(int, input().split()))

    dp = [f_inf] * (n + 1)
    dp[0] = 0
    for c in C:
        for i in range(1, n + 1):
            if i - c >= 0:
                dp[i] = min(dp[i], dp[i - c] + 1)
    print(dp[-1]) resolve n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split dp = [f_inf] * (n + 1) dp [f_inf] * (n + 1) [f_inf] f_inf n + 1 n 1 dp[0] = 0 dp[0] dp 0 0 for c in C:
        for i in range(1, n + 1):
            if i - c >= 0:
                dp[i] = min(dp[i], dp[i - c] + 1)
     c C for i in range(1, n + 1):
            if i - c >= 0:
                dp[i] = min(dp[i], dp[i - c] + 1)
     i range(1, n + 1) range 1 n + 1 n 1 if i - c >= 0:
                dp[i] = min(dp[i], dp[i - c] + 1)
     i - c >= 0 i - c i c 0 dp[i] = min(dp[i], dp[i - c] + 1) dp[i] dp i min(dp[i], dp[i - c] + 1) min dp[i] dp i dp[i - c] + 1 dp[i - c] dp i - c i c 1 print(dp[-1]) print dp[-1] dp -1 if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve input = sys.stdin.readline sys.stdin.readline input mod = 10 ** 9 + 7 10 ** 9 + 7 mod def resolve():
    n, m = map(int, input().split())
    C = list(map(int, input().split()))

    dp = [f_inf] * (n + 1)
    dp[0] = 0
    for c in C:
        for i in range(1, n + 1):
            if i - c >= 0:
                dp[i] = min(dp[i], dp[i - c] + 1)
    print(dp[-1]) def resolve():
    n, m = map(int, input().split())
    C = list(map(int, input().split()))

    dp = [f_inf] * (n + 1)
    dp[0] = 0
    for c in C:
        for i in range(1, n + 1):
            if i - c >= 0:
                dp[i] = min(dp[i], dp[i - c] + 1)
    print(dp[-1]) resolve f_inf = float('inf') float('inf') f_inf
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    C = list(map(int, input().split()))

    dp = [f_inf] * (n + 1)
    dp[0] = 0
    for c in C:
        for i in range(1, n + 1):
            if i - c >= 0:
                dp[i] = min(dp[i], dp[i - c] + 1)
    print(dp[-1])


if __name__ == '__main__':
    resolve()

