def main():
    N, M = map(int, input().split())
    C = list(map(int, input().split()))
    INF = 10**10
    """
    使い回さない方
    dp = [[INF]*(N+1) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] > y:
                dp[i+1][y] = dp[i][y]
            else:
                dp[i+1][y] = min(dp[i][y], dp[i+1][y-C[i]]+1)
    print(min([dp[j][N] for j in range(1, M+1)]))
    """
    """ 使い回す方 """
    dp = [INF]*(N+1)
    dp[0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] <= y:
                dp[y] = min(dp[y], dp[y-C[i]]+1)
    print(dp[N])


if __name__ == "__main__":
    main() def main():
    N, M = map(int, input().split())
    C = list(map(int, input().split()))
    INF = 10**10
    """
    使い回さない方
    dp = [[INF]*(N+1) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] > y:
                dp[i+1][y] = dp[i][y]
            else:
                dp[i+1][y] = min(dp[i][y], dp[i+1][y-C[i]]+1)
    print(min([dp[j][N] for j in range(1, M+1)]))
    """
    """ 使い回す方 """
    dp = [INF]*(N+1)
    dp[0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] <= y:
                dp[y] = min(dp[y], dp[y-C[i]]+1)
    print(dp[N]) main 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 INF = 10**10 INF 10**10 10 10 """
    使い回さない方
    dp = [[INF]*(N+1) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] > y:
                dp[i+1][y] = dp[i][y]
            else:
                dp[i+1][y] = min(dp[i][y], dp[i+1][y-C[i]]+1)
    print(min([dp[j][N] for j in range(1, M+1)]))
    """ """ 使い回す方 """ dp = [INF]*(N+1) dp [INF]*(N+1) [INF] INF N+1 N 1 dp[0] = 0 dp[0] dp 0 0 for i in range(M):
        for y in range(N+1):
            if C[i] <= y:
                dp[y] = min(dp[y], dp[y-C[i]]+1)
     i range(M) range M for y in range(N+1):
            if C[i] <= y:
                dp[y] = min(dp[y], dp[y-C[i]]+1)
     y range(N+1) range N+1 N 1 if C[i] <= y:
                dp[y] = min(dp[y], dp[y-C[i]]+1)
     C[i] <= y C[i] C i y dp[y] = min(dp[y], dp[y-C[i]]+1) dp[y] dp y min(dp[y], dp[y-C[i]]+1) min dp[y] dp y dp[y-C[i]]+1 dp[y-C[i]] dp y-C[i] y C[i] C i 1 print(dp[N]) print dp[N] dp N if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, M = map(int, input().split())
    C = list(map(int, input().split()))
    INF = 10**10
    """
    使い回さない方
    dp = [[INF]*(N+1) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] > y:
                dp[i+1][y] = dp[i][y]
            else:
                dp[i+1][y] = min(dp[i][y], dp[i+1][y-C[i]]+1)
    print(min([dp[j][N] for j in range(1, M+1)]))
    """
    """ 使い回す方 """
    dp = [INF]*(N+1)
    dp[0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] <= y:
                dp[y] = min(dp[y], dp[y-C[i]]+1)
    print(dp[N]) def main():
    N, M = map(int, input().split())
    C = list(map(int, input().split()))
    INF = 10**10
    """
    使い回さない方
    dp = [[INF]*(N+1) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] > y:
                dp[i+1][y] = dp[i][y]
            else:
                dp[i+1][y] = min(dp[i][y], dp[i+1][y-C[i]]+1)
    print(min([dp[j][N] for j in range(1, M+1)]))
    """
    """ 使い回す方 """
    dp = [INF]*(N+1)
    dp[0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] <= y:
                dp[y] = min(dp[y], dp[y-C[i]]+1)
    print(dp[N]) main
def main():
    N, M = map(int, input().split())
    C = list(map(int, input().split()))
    INF = 10**10
    """
    使い回さない方
    dp = [[INF]*(N+1) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] > y:
                dp[i+1][y] = dp[i][y]
            else:
                dp[i+1][y] = min(dp[i][y], dp[i+1][y-C[i]]+1)
    print(min([dp[j][N] for j in range(1, M+1)]))
    """
    """ 使い回す方 """
    dp = [INF]*(N+1)
    dp[0] = 0
    for i in range(M):
        for y in range(N+1):
            if C[i] <= y:
                dp[y] = min(dp[y], dp[y-C[i]]+1)
    print(dp[N])


if __name__ == "__main__":
    main()
