N,M = map(int,input().split())
c = list(map(int,input().split()))
dp = list(range(N+1))
for i in range(N+1):
    for ci in c:
        if i + ci <= N:
            dp[i+ci] = min(dp[i+ci],dp[i] + 1)
print(dp[N])
#print(dp) 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 = list(range(N+1)) dp list(range(N+1)) list range(N+1) range N+1 N 1 for i in range(N+1):
    for ci in c:
        if i + ci <= N:
            dp[i+ci] = min(dp[i+ci],dp[i] + 1) i range(N+1) range N+1 N 1 for ci in c:
        if i + ci <= N:
            dp[i+ci] = min(dp[i+ci],dp[i] + 1) ci c if i + ci <= N:
            dp[i+ci] = min(dp[i+ci],dp[i] + 1) i + ci <= N i + ci i ci N dp[i+ci] = min(dp[i+ci],dp[i] + 1) dp[i+ci] dp i+ci i ci min(dp[i+ci],dp[i] + 1) min dp[i+ci] dp i+ci i ci dp[i] + 1 dp[i] dp i 1 print(dp[N]) print dp[N] dp N M = map(int,input().split()) map(int,input().split()) M c = list(map(int,input().split())) list(map(int,input().split())) c dp = list(range(N+1)) list(range(N+1)) dp N,M = map(int,input().split()) map(int,input().split()) N
N,M = map(int,input().split())
c = list(map(int,input().split()))
dp = list(range(N+1))
for i in range(N+1):
    for ci in c:
        if i + ci <= N:
            dp[i+ci] = min(dp[i+ci],dp[i] + 1)
print(dp[N])
#print(dp)
