import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    c = na()

    dp = [INF for _ in range(n + 1)]
    dp[0] = 0

    for ci in c:
        for i in range(n + 1 - ci):
            dp[i + ci] = min(dp[i + ci], dp[i] + 1)

    print(dp[n])


if __name__ == '__main__':
    main()
 import sys sys import math math import collections collections import bisect bisect import itertools itertools import fractions fractions import copy copy import decimal decimal import queue queue sys.setrecursionlimit(10000001) sys.setrecursionlimit sys setrecursionlimit 10000001 INF = 10 ** 16 INF 10 ** 16 10 16 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 ni = lambda: int(sys.stdin.readline()) ni lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline ns = lambda: map(int, sys.stdin.readline().split()) ns lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split na = lambda: list(map(int, sys.stdin.readline().split())) na lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def main():
    n, m = ns()
    c = na()

    dp = [INF for _ in range(n + 1)]
    dp[0] = 0

    for ci in c:
        for i in range(n + 1 - ci):
            dp[i + ci] = min(dp[i + ci], dp[i] + 1)

    print(dp[n]) main n, m = ns() n ns() ns m c = na() c na() na 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 ci in c:
        for i in range(n + 1 - ci):
            dp[i + ci] = min(dp[i + ci], dp[i] + 1)

     ci c for i in range(n + 1 - ci):
            dp[i + ci] = min(dp[i + ci], dp[i] + 1)

     i range(n + 1 - ci) range n + 1 - ci n + 1 n 1 ci dp[i + ci] = min(dp[i + ci], dp[i] + 1) dp[i + ci] dp i + ci i ci min(dp[i + ci], dp[i] + 1) min dp[i + ci] dp i + ci i ci 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 ns = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) ns INF = 10 ** 16 10 ** 16 INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD na = lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) na def main():
    n, m = ns()
    c = na()

    dp = [INF for _ in range(n + 1)]
    dp[0] = 0

    for ci in c:
        for i in range(n + 1 - ci):
            dp[i + ci] = min(dp[i + ci], dp[i] + 1)

    print(dp[n]) def main():
    n, m = ns()
    c = na()

    dp = [INF for _ in range(n + 1)]
    dp[0] = 0

    for ci in c:
        for i in range(n + 1 - ci):
            dp[i + ci] = min(dp[i + ci], dp[i] + 1)

    print(dp[n]) main ni = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ni
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    c = na()

    dp = [INF for _ in range(n + 1)]
    dp[0] = 0

    for ci in c:
        for i in range(n + 1 - ci):
            dp[i + ci] = min(dp[i + ci], dp[i] + 1)

    print(dp[n])


if __name__ == '__main__':
    main()

