INF = 100 ** 7


def main():
    n, m = map(int, input().split())
    c_list = list(map(int, input().split()))

    dp = [INF] * (n + 1)
    dp[0] = 0
    for c in c_list:
        for i in range(len(dp)):
            if dp[i] != INF and i + c < len(dp):
                dp[i + c] = min(dp[i + c], dp[i] + 1)
    print(dp[n])


if __name__ == '__main__':
    main() INF = 100 ** 7 INF 100 ** 7 100 7 def main():
    n, m = map(int, input().split())
    c_list = list(map(int, input().split()))

    dp = [INF] * (n + 1)
    dp[0] = 0
    for c in c_list:
        for i in range(len(dp)):
            if dp[i] != INF and i + c < len(dp):
                dp[i + c] = min(dp[i + c], dp[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 = list(map(int, input().split())) c_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split dp = [INF] * (n + 1) dp [INF] * (n + 1) [INF] INF n + 1 n 1 dp[0] = 0 dp[0] dp 0 0 for c in c_list:
        for i in range(len(dp)):
            if dp[i] != INF and i + c < len(dp):
                dp[i + c] = min(dp[i + c], dp[i] + 1)
     c c_list for i in range(len(dp)):
            if dp[i] != INF and i + c < len(dp):
                dp[i + c] = min(dp[i + c], dp[i] + 1)
     i range(len(dp)) range len(dp) len dp if dp[i] != INF and i + c < len(dp):
                dp[i + c] = min(dp[i + c], dp[i] + 1)
     dp[i] != INF and i + c < len(dp) dp[i] != INF dp[i] dp i INF i + c < len(dp) i + c i c len(dp) len dp dp[i + c] = min(dp[i + c], dp[i] + 1) dp[i + c] dp i + c i c min(dp[i + c], dp[i] + 1) min dp[i + c] dp i + c i c dp[i] + 1 dp[i] dp i 1 print(dp[n]) print dp[n] dp n if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main INF = 100 ** 7 100 ** 7 INF def main():
    n, m = map(int, input().split())
    c_list = list(map(int, input().split()))

    dp = [INF] * (n + 1)
    dp[0] = 0
    for c in c_list:
        for i in range(len(dp)):
            if dp[i] != INF and i + c < len(dp):
                dp[i + c] = min(dp[i + c], dp[i] + 1)
    print(dp[n]) def main():
    n, m = map(int, input().split())
    c_list = list(map(int, input().split()))

    dp = [INF] * (n + 1)
    dp[0] = 0
    for c in c_list:
        for i in range(len(dp)):
            if dp[i] != INF and i + c < len(dp):
                dp[i + c] = min(dp[i + c], dp[i] + 1)
    print(dp[n]) main
INF = 100 ** 7


def main():
    n, m = map(int, input().split())
    c_list = list(map(int, input().split()))

    dp = [INF] * (n + 1)
    dp[0] = 0
    for c in c_list:
        for i in range(len(dp)):
            if dp[i] != INF and i + c < len(dp):
                dp[i + c] = min(dp[i + c], dp[i] + 1)
    print(dp[n])


if __name__ == '__main__':
    main()