n, m = map(int, input().split())
coin = list(map(int, input().split()))
    
#dp = [[0]*(w+1) for _ in range(n+1)]
#dp[0] = [0]*(w+1)
dp = [999999]*(n+1)
dp[0] = 0

for i in range(1, n+1):
    dp[i] = min([dp[i-coin[j]]+1 if i-coin[j]<n and i-coin[j]>=0 else 999999 for j in range(m)])

            
print(dp[n]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m coin = list(map(int, input().split())) coin list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split dp = [999999]*(n+1) dp [999999]*(n+1) [999999] 999999 n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(1, n+1):
    dp[i] = min([dp[i-coin[j]]+1 if i-coin[j]<n and i-coin[j]>=0 else 999999 for j in range(m)])

             i range(1, n+1) range 1 n+1 n 1 dp[i-coin[j]]+1 if i-coin[j]<n and i-coin[j]>=0 else 999999 for j in range(m) for j in range(m) j range(m) range m for j in range(m) dp[i-coin[j]]+1 if i-coin[j]<n and i-coin[j]>=0 else 999999 i-coin[j]<n and i-coin[j]>=0 i-coin[j]<n i-coin[j] i coin[j] coin j n i-coin[j]>=0 i-coin[j] i coin[j] coin j 0 dp[i-coin[j]]+1 dp[i-coin[j]] dp i-coin[j] i coin[j] coin j 1 999999 dp[i] = min([dp[i-coin[j]]+1 if i-coin[j]<n and i-coin[j]>=0 else 999999 for j in range(m)]) dp[i] dp i min([dp[i-coin[j]]+1 if i-coin[j]<n and i-coin[j]>=0 else 999999 for j in range(m)]) min [dp[i-coin[j]]+1 if i-coin[j]<n and i-coin[j]>=0 else 999999 for j in range(m)] print(dp[n]) print dp[n] dp n n, m = map(int, input().split()) map(int, input().split()) n dp = [999999]*(n+1) [999999]*(n+1) dp coin = list(map(int, input().split())) list(map(int, input().split())) coin m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
coin = list(map(int, input().split()))
    
#dp = [[0]*(w+1) for _ in range(n+1)]
#dp[0] = [0]*(w+1)
dp = [999999]*(n+1)
dp[0] = 0

for i in range(1, n+1):
    dp[i] = min([dp[i-coin[j]]+1 if i-coin[j]<n and i-coin[j]>=0 else 999999 for j in range(m)])

            
print(dp[n])
