n, m = map(int, input().split())
l = list(map(int, input().split()))
dp = [10**5] * (n+1)
dp[0] = 0
for i in range(len(l)):
    m = l[i]
    for j in range(m,n+1):
        dp[j] = min(dp[j-m]+1, dp[j])
print(dp[n]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split dp = [10**5] * (n+1) dp [10**5] * (n+1) [10**5] 10**5 10 5 n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(len(l)):
    m = l[i]
    for j in range(m,n+1):
        dp[j] = min(dp[j-m]+1, dp[j]) i range(len(l)) range len(l) len l m = l[i] m l[i] l i for j in range(m,n+1):
        dp[j] = min(dp[j-m]+1, dp[j]) j range(m,n+1) range m n+1 n 1 dp[j] = min(dp[j-m]+1, dp[j]) dp[j] dp j min(dp[j-m]+1, dp[j]) min dp[j-m]+1 dp[j-m] dp j-m j m 1 dp[j] dp j print(dp[n]) print dp[n] dp n m = map(int, input().split()) map(int, input().split()) m m = l[i] l[i] m n, m = map(int, input().split()) map(int, input().split()) n l = list(map(int, input().split())) list(map(int, input().split())) l dp = [10**5] * (n+1) [10**5] * (n+1) dp
n, m = map(int, input().split())
l = list(map(int, input().split()))
dp = [10**5] * (n+1)
dp[0] = 0
for i in range(len(l)):
    m = l[i]
    for j in range(m,n+1):
        dp[j] = min(dp[j-m]+1, dp[j])
print(dp[n])
