# https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_A

INF = float('inf')

if __name__ == "__main__":
    N, M = list(map(int, input().split()))
    C = list(map(int, input().split()))
    dp = [INF for _ in range(N+1)]
    dp[0] = 0

    for i in range(M):
        c = C[i]
        for n in range(c, N+1):
            if dp[n-c] == INF:
                continue
            else:
                dp[n] = min(dp[n-c] + 1, dp[n])

    print(dp[N])
 INF = float('inf') INF float('inf') float 'inf' if __name__ == "__main__":
    N, M = list(map(int, input().split()))
    C = list(map(int, input().split()))
    dp = [INF for _ in range(N+1)]
    dp[0] = 0

    for i in range(M):
        c = C[i]
        for n in range(c, N+1):
            if dp[n-c] == INF:
                continue
            else:
                dp[n] = min(dp[n-c] + 1, dp[n])

    print(dp[N]) __name__ == "__main__" __name__ "__main__" N, M = list(map(int, input().split())) N list(map(int, input().split())) list 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 INF for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) INF dp = [INF for _ in range(N+1)] dp [INF for _ in range(N+1)] dp[0] = 0 dp[0] dp 0 0 for i in range(M):
        c = C[i]
        for n in range(c, N+1):
            if dp[n-c] == INF:
                continue
            else:
                dp[n] = min(dp[n-c] + 1, dp[n])

     i range(M) range M c = C[i] c C[i] C i for n in range(c, N+1):
            if dp[n-c] == INF:
                continue
            else:
                dp[n] = min(dp[n-c] + 1, dp[n])

     n range(c, N+1) range c N+1 N 1 if dp[n-c] == INF:
                continue
            else:
                dp[n] = min(dp[n-c] + 1, dp[n])

     dp[n-c] == INF dp[n-c] dp n-c n c INF continue dp[n] = min(dp[n-c] + 1, dp[n]) dp[n] dp n min(dp[n-c] + 1, dp[n]) min dp[n-c] + 1 dp[n-c] dp n-c n c 1 dp[n] dp n print(dp[N]) print dp[N] dp N dp = [INF for _ in range(N+1)] [INF for _ in range(N+1)] dp M = list(map(int, input().split())) list(map(int, input().split())) M N, M = list(map(int, input().split())) list(map(int, input().split())) N c = C[i] C[i] c INF = float('inf') float('inf') INF C = list(map(int, input().split())) list(map(int, input().split())) C
# https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_A

INF = float('inf')

if __name__ == "__main__":
    N, M = list(map(int, input().split()))
    C = list(map(int, input().split()))
    dp = [INF for _ in range(N+1)]
    dp[0] = 0

    for i in range(M):
        c = C[i]
        for n in range(c, N+1):
            if dp[n-c] == INF:
                continue
            else:
                dp[n] = min(dp[n-c] + 1, dp[n])

    print(dp[N])

