import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m,*c = map(int,read().split())
INF = 9**9
dp = [INF] * (n+1)

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

print(dp[n])
 import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines n,m,*c = map(int,read().split()) n map(int,read().split()) map int read().split() ().split () read split m *c c INF = 9**9 INF 9**9 9 9 dp = [INF] * (n+1) dp [INF] * (n+1) [INF] INF n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for i in range(1,n+1):
    for j in c:
        if i-j>= 0:
            dp[i] = min(dp[i],dp[i-j]+1) i range(1,n+1) range 1 n+1 n 1 for j in c:
        if i-j>= 0:
            dp[i] = min(dp[i],dp[i-j]+1) j c if i-j>= 0:
            dp[i] = min(dp[i],dp[i-j]+1) i-j>= 0 i-j i j 0 dp[i] = min(dp[i],dp[i-j]+1) dp[i] dp i min(dp[i],dp[i-j]+1) min dp[i] dp i dp[i-j]+1 dp[i-j] dp i-j i j 1 print(dp[n]) print dp[n] dp n n,m,*c = map(int,read().split()) map(int,read().split()) n readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline read = sys.stdin.buffer.read sys.stdin.buffer.read read dp = [INF] * (n+1) [INF] * (n+1) dp readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines INF = 9**9 9**9 INF m,*c = map(int,read().split()) map(int,read().split()) m
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m,*c = map(int,read().split())
INF = 9**9
dp = [INF] * (n+1)

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

print(dp[n])

