n, m = map(int, input().split())
li_c = list(map(int, input().split()))

INF = 10**7
dp = [INF]*(50010)
dp[0] = 0
dp[1] = 1
# dp[i] : i 円支払う時の最小の枚数
for i in range(50001):
    for coin in li_c:
        if i+coin<50010:
            dp[i+coin] = min(dp[i]+1, dp[i+coin])
print(dp[n])

 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m li_c = list(map(int, input().split())) li_c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split INF = 10**7 INF 10**7 10 7 dp = [INF]*(50010) dp [INF]*(50010) [INF] INF 50010 dp[0] = 0 dp[0] dp 0 0 dp[1] = 1 dp[1] dp 1 1 for i in range(50001):
    for coin in li_c:
        if i+coin<50010:
            dp[i+coin] = min(dp[i]+1, dp[i+coin]) i range(50001) range 50001 for coin in li_c:
        if i+coin<50010:
            dp[i+coin] = min(dp[i]+1, dp[i+coin]) coin li_c if i+coin<50010:
            dp[i+coin] = min(dp[i]+1, dp[i+coin]) i+coin<50010 i+coin i coin 50010 dp[i+coin] = min(dp[i]+1, dp[i+coin]) dp[i+coin] dp i+coin i coin min(dp[i]+1, dp[i+coin]) min dp[i]+1 dp[i] dp i 1 dp[i+coin] dp i+coin i coin print(dp[n]) print dp[n] dp n dp = [INF]*(50010) [INF]*(50010) dp n, m = map(int, input().split()) map(int, input().split()) n li_c = list(map(int, input().split())) list(map(int, input().split())) li_c INF = 10**7 10**7 INF m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
li_c = list(map(int, input().split()))

INF = 10**7
dp = [INF]*(50010)
dp[0] = 0
dp[1] = 1
# dp[i] : i 円支払う時の最小の枚数
for i in range(50001):
    for coin in li_c:
        if i+coin<50010:
            dp[i+coin] = min(dp[i]+1, dp[i+coin])
print(dp[n])


