N,M=map(int,input().split())
C=list(map(int,input().split()))

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

DP=[i for i in range(N+1)]
#print(DP)
for coin in C:
    for pay in range(N+1):
        if pay-coin>=0:
            DP[pay]=min(DP[pay],DP[pay-coin]+1)
#print(DP[-1])
print(DP[-1])
