#!/usr/bin/env python2
# coding: utf-8

n, m = map(int, raw_input().split())
c = map(int, raw_input().split())

dp = ['inf'] * 50001
dp[0] = 0;

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

print dp[n]
 n, m = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split m c = map(int, raw_input().split()) c map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split dp = ['inf'] * 50001 dp ['inf'] * 50001 ['inf'] 'inf' 50001 dp[0] = 0 dp[0] dp 0 0 for i in range(m):
    for j in range(n+1):
        if j + c[i] > n:
            break
        else:
            dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1) i range(m) range m for j in range(n+1):
        if j + c[i] > n:
            break
        else:
            dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1) j range(n+1) range n+1 n 1 if j + c[i] > n:
            break
        else:
            dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1) j + c[i] > n j + c[i] j c[i] c i n break dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1) dp[j + c[i]] dp j + c[i] j c[i] c i min(dp[j + c[i]], dp[j] + 1) min dp[j + c[i]] dp j + c[i] j c[i] c i dp[j] + 1 dp[j] dp j 1 print dp[n] dp n c = map(int, raw_input().split()) map(int, raw_input().split()) c n, m = map(int, raw_input().split()) map(int, raw_input().split()) n m = map(int, raw_input().split()) map(int, raw_input().split()) m dp = ['inf'] * 50001 ['inf'] * 50001 dp
#!/usr/bin/env python2
# coding: utf-8

n, m = map(int, raw_input().split())
c = map(int, raw_input().split())

dp = ['inf'] * 50001
dp[0] = 0;

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

print dp[n]

