INF = 1145141919810364364334

n,m = map(int,input().split())
c = list(map(int,input().split()))
dp = [INF] * (n+1)
dp[0] = 0

for i in range(m):
    for j in range(n+1):
        if c[i] > j:
            continue
        else:
            dp[j] = min(dp[j] , dp[j-c[i]] + 1)
            
print(dp[n]) INF = 1145141919810364364334 INF 1145141919810364364334 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 = [INF] * (n+1) dp [INF] * (n+1) [INF] INF n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(m):
    for j in range(n+1):
        if c[i] > j:
            continue
        else:
            dp[j] = min(dp[j] , dp[j-c[i]] + 1)
             i range(m) range m for j in range(n+1):
        if c[i] > j:
            continue
        else:
            dp[j] = min(dp[j] , dp[j-c[i]] + 1)
             j range(n+1) range n+1 n 1 if c[i] > j:
            continue
        else:
            dp[j] = min(dp[j] , dp[j-c[i]] + 1)
             c[i] > j c[i] c i j continue dp[j] = min(dp[j] , dp[j-c[i]] + 1) dp[j] dp j min(dp[j] , dp[j-c[i]] + 1) min dp[j] dp j dp[j-c[i]] + 1 dp[j-c[i]] dp j-c[i] j c[i] c i 1 print(dp[n]) print dp[n] dp n c = list(map(int,input().split())) list(map(int,input().split())) c dp = [INF] * (n+1) [INF] * (n+1) dp INF = 1145141919810364364334 1145141919810364364334 INF n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m
INF = 1145141919810364364334

n,m = map(int,input().split())
c = list(map(int,input().split()))
dp = [INF] * (n+1)
dp[0] = 0

for i in range(m):
    for j in range(n+1):
        if c[i] > j:
            continue
        else:
            dp[j] = min(dp[j] , dp[j-c[i]] + 1)
            
print(dp[n])
