N, M = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

dp = [50001] * (N + 1)
dp[0] = 0

for c in C:
    for n in range(c, N + 1):
        dp[n] = min(dp[n], dp[n - c] + 1)

print(dp[-1]) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x N, M = [int(x) for x in input().split()] N [int(x) for x in input().split()] M int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x C = [int(x) for x in input().split()] C [int(x) for x in input().split()] dp = [50001] * (N + 1) dp [50001] * (N + 1) [50001] 50001 N + 1 N 1 dp[0] = 0 dp[0] dp 0 0 for c in C:
    for n in range(c, N + 1):
        dp[n] = min(dp[n], dp[n - c] + 1) c C for n in range(c, N + 1):
        dp[n] = min(dp[n], dp[n - c] + 1) n range(c, N + 1) range c N + 1 N 1 dp[n] = min(dp[n], dp[n - c] + 1) dp[n] dp n min(dp[n], dp[n - c] + 1) min dp[n] dp n dp[n - c] + 1 dp[n - c] dp n - c n c 1 print(dp[-1]) print dp[-1] dp -1 C = [int(x) for x in input().split()] [int(x) for x in input().split()] C dp = [50001] * (N + 1) [50001] * (N + 1) dp N, M = [int(x) for x in input().split()] [int(x) for x in input().split()] N M = [int(x) for x in input().split()] [int(x) for x in input().split()] M
N, M = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

dp = [50001] * (N + 1)
dp[0] = 0

for c in C:
    for n in range(c, N + 1):
        dp[n] = min(dp[n], dp[n - c] + 1)

print(dp[-1])
