cap, m = map(int, input().split())
arr = list(map(int, input().split()))

INF = 1 << 60
dp = [INF] * (cap + 1)
dp[0] = 0

for x in arr:
    for i in range(x, cap + 1):
        dp[i] = min(dp[i], dp[i - x] + 1)

print(dp[cap]) cap, m = map(int, input().split()) cap map(int, input().split()) map int input().split() ().split () input split m arr = list(map(int, input().split())) arr list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split INF = 1 << 60 INF 1 << 60 1 60 dp = [INF] * (cap + 1) dp [INF] * (cap + 1) [INF] INF cap + 1 cap 1 dp[0] = 0 dp[0] dp 0 0 for x in arr:
    for i in range(x, cap + 1):
        dp[i] = min(dp[i], dp[i - x] + 1) x arr for i in range(x, cap + 1):
        dp[i] = min(dp[i], dp[i - x] + 1) i range(x, cap + 1) range x cap + 1 cap 1 dp[i] = min(dp[i], dp[i - x] + 1) dp[i] dp i min(dp[i], dp[i - x] + 1) min dp[i] dp i dp[i - x] + 1 dp[i - x] dp i - x i x 1 print(dp[cap]) print dp[cap] dp cap INF = 1 << 60 1 << 60 INF arr = list(map(int, input().split())) list(map(int, input().split())) arr m = map(int, input().split()) map(int, input().split()) m cap, m = map(int, input().split()) map(int, input().split()) cap dp = [INF] * (cap + 1) [INF] * (cap + 1) dp
cap, m = map(int, input().split())
arr = list(map(int, input().split()))

INF = 1 << 60
dp = [INF] * (cap + 1)
dp[0] = 0

for x in arr:
    for i in range(x, cap + 1):
        dp[i] = min(dp[i], dp[i - x] + 1)

print(dp[cap])
