n, m = map(int, input().split())
c = list(map(int, input().split())) #0-index

# dp[i+1][x]:i種類のコインを使ってxを支払う際の最小のコイン枚数
dp = [[float('inf')]*(n+1) for _ in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for x in range(n+1):
        dp[i+1][x] = dp[i][x]

        if x -c[i]>= 0:
            dp[i+1][x] = min(dp[i+1][x - c[i]] + 1, dp[i][x])
print(dp[m][n]) 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 [float('inf')]*(n+1) for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [float('inf')]*(n+1) [float('inf')] float('inf') float 'inf' n+1 n 1 dp = [[float('inf')]*(n+1) for _ in range(m+1)] dp [[float('inf')]*(n+1) for _ in range(m+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    for x in range(n+1):
        dp[i+1][x] = dp[i][x]

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

        if x -c[i]>= 0:
            dp[i+1][x] = min(dp[i+1][x - c[i]] + 1, dp[i][x]) x range(n+1) range n+1 n 1 dp[i+1][x] = dp[i][x] dp[i+1][x] [i+1] dp i+1 i 1 x dp[i][x] [i] dp i x if x -c[i]>= 0:
            dp[i+1][x] = min(dp[i+1][x - c[i]] + 1, dp[i][x]) x -c[i]>= 0 x -c[i] x c[i] c i 0 dp[i+1][x] = min(dp[i+1][x - c[i]] + 1, dp[i][x]) dp[i+1][x] [i+1] dp i+1 i 1 x min(dp[i+1][x - c[i]] + 1, dp[i][x]) min dp[i+1][x - c[i]] + 1 dp[i+1][x - c[i]] [i+1] dp i+1 i 1 x - c[i] x c[i] c i 1 dp[i][x] [i] dp i x print(dp[m][n]) print dp[m][n] [m] dp m n m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n dp = [[float('inf')]*(n+1) for _ in range(m+1)] [[float('inf')]*(n+1) for _ in range(m+1)] 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())) #0-index

# dp[i+1][x]:i種類のコインを使ってxを支払う際の最小のコイン枚数
dp = [[float('inf')]*(n+1) for _ in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for x in range(n+1):
        dp[i+1][x] = dp[i][x]

        if x -c[i]>= 0:
            dp[i+1][x] = min(dp[i+1][x - c[i]] + 1, dp[i][x])
print(dp[m][n])
