n,m=map(int,input().split())
c=list(map(int,input().split()))
dp=[[10001]*m for i in range(n)] #dp[value][i_coin]
dp.insert(0,[0]*m)
for i in range(m):
  for v in range(1,n+1):
    if i==0:
      dp[v][i]=v//c[i] if v%c[i]==0 else 10001
      continue
    if v<c[i]:
        dp[v][i]=dp[v][i-1]
    else:
      dp[v][i]=min(dp[v][i-1],dp[v-c[i]][i]+1)
print(dp[n][m-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m c=list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split [10001]*m for i in range(n) for i in range(n) i range(n) range n for i in range(n) [10001]*m [10001] 10001 m dp=[[10001]*m for i in range(n)] dp [[10001]*m for i in range(n)] dp.insert(0,[0]*m) dp.insert dp insert 0 [0]*m [0] 0 m for i in range(m):
  for v in range(1,n+1):
    if i==0:
      dp[v][i]=v//c[i] if v%c[i]==0 else 10001
      continue
    if v<c[i]:
        dp[v][i]=dp[v][i-1]
    else:
      dp[v][i]=min(dp[v][i-1],dp[v-c[i]][i]+1) i range(m) range m for v in range(1,n+1):
    if i==0:
      dp[v][i]=v//c[i] if v%c[i]==0 else 10001
      continue
    if v<c[i]:
        dp[v][i]=dp[v][i-1]
    else:
      dp[v][i]=min(dp[v][i-1],dp[v-c[i]][i]+1) v range(1,n+1) range 1 n+1 n 1 if i==0:
      dp[v][i]=v//c[i] if v%c[i]==0 else 10001
      continue
     i==0 i 0 dp[v][i]=v//c[i] if v%c[i]==0 else 10001 dp[v][i] [v] dp v i v//c[i] if v%c[i]==0 else 10001 v%c[i]==0 v%c[i] v c[i] c i 0 v//c[i] v c[i] c i 10001 continue if v<c[i]:
        dp[v][i]=dp[v][i-1]
    else:
      dp[v][i]=min(dp[v][i-1],dp[v-c[i]][i]+1) v<c[i] v c[i] c i dp[v][i]=dp[v][i-1] dp[v][i] [v] dp v i dp[v][i-1] [v] dp v i-1 i 1 dp[v][i]=min(dp[v][i-1],dp[v-c[i]][i]+1) dp[v][i] [v] dp v i min(dp[v][i-1],dp[v-c[i]][i]+1) min dp[v][i-1] [v] dp v i-1 i 1 dp[v-c[i]][i]+1 dp[v-c[i]][i] [v-c[i]] dp v-c[i] v c[i] c i i 1 print(dp[n][m-1]) print dp[n][m-1] [n] dp n m-1 m 1 n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m dp=[[10001]*m for i in range(n)] [[10001]*m for i in range(n)] dp c=list(map(int,input().split())) list(map(int,input().split())) c
n,m=map(int,input().split())
c=list(map(int,input().split()))
dp=[[10001]*m for i in range(n)] #dp[value][i_coin]
dp.insert(0,[0]*m)
for i in range(m):
  for v in range(1,n+1):
    if i==0:
      dp[v][i]=v//c[i] if v%c[i]==0 else 10001
      continue
    if v<c[i]:
        dp[v][i]=dp[v][i-1]
    else:
      dp[v][i]=min(dp[v][i-1],dp[v-c[i]][i]+1)
print(dp[n][m-1])
