# coding: utf-8
# Your code here!
s = input().split()
n = int(s[0])#price
m = int(s[1])#num of kind

coins = input().split()


min_count = [99999 for i in range(n)]

for j in range(m):
    coins[j] = int(coins[j])
    
for i in range(n):
    buf = 99999
    if i+1 in coins:
        min_count[i] = 1
        continue
    for j in coins:
        if i<j: continue
        buf = min(buf,min_count[i-j]+1)
    min_count[i] = buf
    
print(min_count[n-1]) s = input().split() s input().split() ().split () input split n = int(s[0]) n int(s[0]) int s[0] s 0 m = int(s[1]) m int(s[1]) int s[1] s 1 coins = input().split() coins input().split() ().split () input split 99999 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 99999 min_count = [99999 for i in range(n)] min_count [99999 for i in range(n)] for j in range(m):
    coins[j] = int(coins[j])
     j range(m) range m coins[j] = int(coins[j]) coins[j] coins j int(coins[j]) int coins[j] coins j for i in range(n):
    buf = 99999
    if i+1 in coins:
        min_count[i] = 1
        continue
    for j in coins:
        if i<j: continue
        buf = min(buf,min_count[i-j]+1)
    min_count[i] = buf
     i range(n) range n buf = 99999 buf 99999 if i+1 in coins:
        min_count[i] = 1
        continue
     i+1 in coins i+1 i 1 coins min_count[i] = 1 min_count[i] min_count i 1 continue for j in coins:
        if i<j: continue
        buf = min(buf,min_count[i-j]+1)
     j coins if i<j: continue
         i<j i j buf = min(buf,min_count[i-j]+1) buf min(buf,min_count[i-j]+1) min buf min_count[i-j]+1 min_count[i-j] min_count i-j i j 1 min_count[i] = buf min_count[i] min_count i buf print(min_count[n-1]) print min_count[n-1] min_count n-1 n 1 n = int(s[0]) int(s[0]) n min_count = [99999 for i in range(n)] [99999 for i in range(n)] min_count s = input().split() input().split() s buf = min(buf,min_count[i-j]+1) min(buf,min_count[i-j]+1) buf buf = 99999 99999 buf m = int(s[1]) int(s[1]) m coins = input().split() input().split() coins
# coding: utf-8
# Your code here!
s = input().split()
n = int(s[0])#price
m = int(s[1])#num of kind

coins = input().split()


min_count = [99999 for i in range(n)]

for j in range(m):
    coins[j] = int(coins[j])
    
for i in range(n):
    buf = 99999
    if i+1 in coins:
        min_count[i] = 1
        continue
    for j in coins:
        if i<j: continue
        buf = min(buf,min_count[i-j]+1)
    min_count[i] = buf
    
print(min_count[n-1])
