n,m=map(int,input().split())
c=sorted(list(map(int,input().split())))
dp=[10**18]*(n+1)
for i in c:
  if i>n:break
  dp[i]=1
  for j in range(i+1,n+1):
    dp[j]=min(dp[j],dp[j-i]+1)
print(dp[n]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m c=sorted(list(map(int,input().split()))) c sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split dp=[10**18]*(n+1) dp [10**18]*(n+1) [10**18] 10**18 10 18 n+1 n 1 for i in c:
  if i>n:break
  dp[i]=1
  for j in range(i+1,n+1):
    dp[j]=min(dp[j],dp[j-i]+1) i c if i>n:break
   i>n i n dp[i]=1 dp[i] dp i 1 for j in range(i+1,n+1):
    dp[j]=min(dp[j],dp[j-i]+1) j range(i+1,n+1) range i+1 i 1 n+1 n 1 dp[j]=min(dp[j],dp[j-i]+1) dp[j] dp j min(dp[j],dp[j-i]+1) min dp[j] dp j dp[j-i]+1 dp[j-i] dp j-i j i 1 print(dp[n]) print dp[n] dp n c=sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) c m=map(int,input().split()) map(int,input().split()) m dp=[10**18]*(n+1) [10**18]*(n+1) dp n,m=map(int,input().split()) map(int,input().split()) n
n,m=map(int,input().split())
c=sorted(list(map(int,input().split())))
dp=[10**18]*(n+1)
for i in c:
  if i>n:break
  dp[i]=1
  for j in range(i+1,n+1):
    dp[j]=min(dp[j],dp[j-i]+1)
print(dp[n])
