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

dp = [[0]*len(C) for n in range(N+1)] #dp[n][c]

for n in range(1,N+1):
    dp[n][0] = n
    
for n in range(1,N+1):
    for c in range(1,len(C)):
        if C[c] > n:
            dp[n][c]=dp[n][c-1]
        else:
            dp[n][c]=min(dp[n][c-1],dp[n-C[c]][c]+1)
            
print(dp[-1][-1]) N,M=list(map(int,input().split())) N list(map(int,input().split())) list 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 [0]*len(C) for n in range(N+1) for n in range(N+1) n range(N+1) range N+1 N 1 for n in range(N+1) [0]*len(C) [0] 0 len(C) len C dp = [[0]*len(C) for n in range(N+1)] dp [[0]*len(C) for n in range(N+1)] for n in range(1,N+1):
    dp[n][0] = n
     n range(1,N+1) range 1 N+1 N 1 dp[n][0] = n dp[n][0] [n] dp n 0 n for n in range(1,N+1):
    for c in range(1,len(C)):
        if C[c] > n:
            dp[n][c]=dp[n][c-1]
        else:
            dp[n][c]=min(dp[n][c-1],dp[n-C[c]][c]+1)
             n range(1,N+1) range 1 N+1 N 1 for c in range(1,len(C)):
        if C[c] > n:
            dp[n][c]=dp[n][c-1]
        else:
            dp[n][c]=min(dp[n][c-1],dp[n-C[c]][c]+1)
             c range(1,len(C)) range 1 len(C) len C if C[c] > n:
            dp[n][c]=dp[n][c-1]
        else:
            dp[n][c]=min(dp[n][c-1],dp[n-C[c]][c]+1)
             C[c] > n C[c] C c n dp[n][c]=dp[n][c-1] dp[n][c] [n] dp n c dp[n][c-1] [n] dp n c-1 c 1 dp[n][c]=min(dp[n][c-1],dp[n-C[c]][c]+1) dp[n][c] [n] dp n c min(dp[n][c-1],dp[n-C[c]][c]+1) min dp[n][c-1] [n] dp n c-1 c 1 dp[n-C[c]][c]+1 dp[n-C[c]][c] [n-C[c]] dp n-C[c] n C[c] C c c 1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 C=list(map(int,input().split())) list(map(int,input().split())) C dp = [[0]*len(C) for n in range(N+1)] [[0]*len(C) for n in range(N+1)] dp M=list(map(int,input().split())) list(map(int,input().split())) M N,M=list(map(int,input().split())) list(map(int,input().split())) N
N,M=list(map(int,input().split()))
C=list(map(int,input().split()))

dp = [[0]*len(C) for n in range(N+1)] #dp[n][c]

for n in range(1,N+1):
    dp[n][0] = n
    
for n in range(1,N+1):
    for c in range(1,len(C)):
        if C[c] > n:
            dp[n][c]=dp[n][c-1]
        else:
            dp[n][c]=min(dp[n][c-1],dp[n-C[c]][c]+1)
            
print(dp[-1][-1])
