#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

n,m=map(int,input().split())
A=list(map(int,input().split()))
dp=[inf]*(n+1)
dp[0]=0
for a in A:
    for i in range(a,n+1):
        dp[i]=min(dp[i],dp[i-a]+1)
print(dp[n])
 import sys, math sys math input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') input lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.stdin.buffer.readline().rstrip().decode sys.stdin.buffer.readline().rstrip() sys.stdin.buffer.readline().rstrip sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline rstrip decode 'utf-8' sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 inf = float('inf') inf float('inf') float 'inf' ans=count=0 ans 0 =count=0 count 0 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m A=list(map(int,input().split())) A list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split dp=[inf]*(n+1) dp [inf]*(n+1) [inf] inf n+1 n 1 dp[0]=0 dp[0] dp 0 0 for a in A:
    for i in range(a,n+1):
        dp[i]=min(dp[i],dp[i-a]+1) a A for i in range(a,n+1):
        dp[i]=min(dp[i],dp[i-a]+1) i range(a,n+1) range a n+1 n 1 dp[i]=min(dp[i],dp[i-a]+1) dp[i] dp i min(dp[i],dp[i-a]+1) min dp[i] dp i dp[i-a]+1 dp[i-a] dp i-a i a 1 print(dp[n]) print dp[n] dp n input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') input dp=[inf]*(n+1) [inf]*(n+1) dp m=map(int,input().split()) map(int,input().split()) m n,m=map(int,input().split()) map(int,input().split()) n count=0 0 count ans=count=0 0 ans A=list(map(int,input().split())) list(map(int,input().split())) A inf = float('inf') float('inf') inf
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

n,m=map(int,input().split())
A=list(map(int,input().split()))
dp=[inf]*(n+1)
dp[0]=0
for a in A:
    for i in range(a,n+1):
        dp[i]=min(dp[i],dp[i-a]+1)
print(dp[n])

