import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    c = list(map(int, input().split()))

    dp = [i+100 for i in range(N+1)]
    dp[0] = 0

    for i in range(1, N+1):
        for t in c:
            if i - t >= 0:
                dp[i] = min(dp[i], dp[i-t] + 1)
    # print(dp)
    print(dp[N])

if __name__ == "__main__":
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N, M = map(int, input().split())
    c = list(map(int, input().split()))

    dp = [i+100 for i in range(N+1)]
    dp[0] = 0

    for i in range(1, N+1):
        for t in c:
            if i - t >= 0:
                dp[i] = min(dp[i], dp[i-t] + 1)
    # print(dp)
    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 i+100 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) i+100 i 100 dp = [i+100 for i in range(N+1)] dp [i+100 for i in range(N+1)] dp[0] = 0 dp[0] dp 0 0 for i in range(1, N+1):
        for t in c:
            if i - t >= 0:
                dp[i] = min(dp[i], dp[i-t] + 1)
    # print(dp)
     i range(1, N+1) range 1 N+1 N 1 for t in c:
            if i - t >= 0:
                dp[i] = min(dp[i], dp[i-t] + 1)
    # print(dp)
     t c if i - t >= 0:
                dp[i] = min(dp[i], dp[i-t] + 1)
    # print(dp)
     i - t >= 0 i - t i t 0 dp[i] = min(dp[i], dp[i-t] + 1) dp[i] dp i min(dp[i], dp[i-t] + 1) min dp[i] dp i dp[i-t] + 1 dp[i-t] dp i-t i t 1 print(dp[N]) print dp[N] dp N if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = sys.stdin.readline sys.stdin.readline input def main():
    N, M = map(int, input().split())
    c = list(map(int, input().split()))

    dp = [i+100 for i in range(N+1)]
    dp[0] = 0

    for i in range(1, N+1):
        for t in c:
            if i - t >= 0:
                dp[i] = min(dp[i], dp[i-t] + 1)
    # print(dp)
    print(dp[N]) def main():
    N, M = map(int, input().split())
    c = list(map(int, input().split()))

    dp = [i+100 for i in range(N+1)]
    dp[0] = 0

    for i in range(1, N+1):
        for t in c:
            if i - t >= 0:
                dp[i] = min(dp[i], dp[i-t] + 1)
    # print(dp)
    print(dp[N]) main
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    c = list(map(int, input().split()))

    dp = [i+100 for i in range(N+1)]
    dp[0] = 0

    for i in range(1, N+1):
        for t in c:
            if i - t >= 0:
                dp[i] = min(dp[i], dp[i-t] + 1)
    # print(dp)
    print(dp[N])

if __name__ == "__main__":
    main()
