# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=ja
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    n,m,*C = map(int, read().split())

    # dp[i] := i円を作るのに必要な最小枚数
    dp = [10**10] * (n+1)
    dp[0] = 0

    for c in C:
        for i in range(n+1):
            if i + c <= n:
                dp[i+c] = min(dp[i] + 1, dp[i+c])

    print(dp[n])


if __name__ == "__main__":
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines def main():
    n,m,*C = map(int, read().split())

    # dp[i] := i円を作るのに必要な最小枚数
    dp = [10**10] * (n+1)
    dp[0] = 0

    for c in C:
        for i in range(n+1):
            if i + c <= n:
                dp[i+c] = min(dp[i] + 1, dp[i+c])

    print(dp[n]) main n,m,*C = map(int, read().split()) n map(int, read().split()) map int read().split() ().split () read split m *C C dp = [10**10] * (n+1) dp [10**10] * (n+1) [10**10] 10**10 10 10 n+1 n 1 dp[0] = 0 dp[0] dp 0 0 for c in C:
        for i in range(n+1):
            if i + c <= n:
                dp[i+c] = min(dp[i] + 1, dp[i+c])

     c C for i in range(n+1):
            if i + c <= n:
                dp[i+c] = min(dp[i] + 1, dp[i+c])

     i range(n+1) range n+1 n 1 if i + c <= n:
                dp[i+c] = min(dp[i] + 1, dp[i+c])

     i + c <= n i + c i c n dp[i+c] = min(dp[i] + 1, dp[i+c]) dp[i+c] dp i+c i c min(dp[i] + 1, dp[i+c]) min dp[i] + 1 dp[i] dp i 1 dp[i+c] dp i+c i c print(dp[n]) print dp[n] dp n if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main readlines = sys.stdin.readlines sys.stdin.readlines readlines read = sys.stdin.read sys.stdin.read read readline = sys.stdin.readline sys.stdin.readline readline def main():
    n,m,*C = map(int, read().split())

    # dp[i] := i円を作るのに必要な最小枚数
    dp = [10**10] * (n+1)
    dp[0] = 0

    for c in C:
        for i in range(n+1):
            if i + c <= n:
                dp[i+c] = min(dp[i] + 1, dp[i+c])

    print(dp[n]) def main():
    n,m,*C = map(int, read().split())

    # dp[i] := i円を作るのに必要な最小枚数
    dp = [10**10] * (n+1)
    dp[0] = 0

    for c in C:
        for i in range(n+1):
            if i + c <= n:
                dp[i+c] = min(dp[i] + 1, dp[i+c])

    print(dp[n]) main
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=ja
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    n,m,*C = map(int, read().split())

    # dp[i] := i円を作るのに必要な最小枚数
    dp = [10**10] * (n+1)
    dp[0] = 0

    for c in C:
        for i in range(n+1):
            if i + c <= n:
                dp[i+c] = min(dp[i] + 1, dp[i+c])

    print(dp[n])


if __name__ == "__main__":
    main()
