# -*- coding:utf-8 -*-

def solve():
    import sys

    N, M = list(map(int, sys.stdin.readline().split()))
    Cs = list(map(int, sys.stdin.readline().split()))

    dp = [float("inf") for _ in range(N+1)]  # dp[i] := i円を作ることができるコインの最小枚数
    dp[0] = 0

    for c in Cs:
        for i in range(c, N+1):
            dp[i] = min(dp[i], dp[i-c]+1)
    print(dp[N])


if __name__ == "__main__":
    solve()
 def solve():
    import sys

    N, M = list(map(int, sys.stdin.readline().split()))
    Cs = list(map(int, sys.stdin.readline().split()))

    dp = [float("inf") for _ in range(N+1)]  # dp[i] := i円を作ることができるコインの最小枚数
    dp[0] = 0

    for c in Cs:
        for i in range(c, N+1):
            dp[i] = min(dp[i], dp[i-c]+1)
    print(dp[N]) solve import sys sys N, M = list(map(int, sys.stdin.readline().split())) N 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 M Cs = list(map(int, sys.stdin.readline().split())) Cs 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 float("inf") for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) float("inf") float "inf" dp = [float("inf") for _ in range(N+1)] dp [float("inf") for _ in range(N+1)] dp[0] = 0 dp[0] dp 0 0 for c in Cs:
        for i in range(c, N+1):
            dp[i] = min(dp[i], dp[i-c]+1)
     c Cs for i in range(c, N+1):
            dp[i] = min(dp[i], dp[i-c]+1)
     i range(c, N+1) range c N+1 N 1 dp[i] = min(dp[i], dp[i-c]+1) dp[i] dp i min(dp[i], dp[i-c]+1) min dp[i] dp i dp[i-c]+1 dp[i-c] dp i-c i c 1 print(dp[N]) print dp[N] dp N if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    import sys

    N, M = list(map(int, sys.stdin.readline().split()))
    Cs = list(map(int, sys.stdin.readline().split()))

    dp = [float("inf") for _ in range(N+1)]  # dp[i] := i円を作ることができるコインの最小枚数
    dp[0] = 0

    for c in Cs:
        for i in range(c, N+1):
            dp[i] = min(dp[i], dp[i-c]+1)
    print(dp[N]) def solve():
    import sys

    N, M = list(map(int, sys.stdin.readline().split()))
    Cs = list(map(int, sys.stdin.readline().split()))

    dp = [float("inf") for _ in range(N+1)]  # dp[i] := i円を作ることができるコインの最小枚数
    dp[0] = 0

    for c in Cs:
        for i in range(c, N+1):
            dp[i] = min(dp[i], dp[i-c]+1)
    print(dp[N]) solve
# -*- coding:utf-8 -*-

def solve():
    import sys

    N, M = list(map(int, sys.stdin.readline().split()))
    Cs = list(map(int, sys.stdin.readline().split()))

    dp = [float("inf") for _ in range(N+1)]  # dp[i] := i円を作ることができるコインの最小枚数
    dp[0] = 0

    for c in Cs:
        for i in range(c, N+1):
            dp[i] = min(dp[i], dp[i-c]+1)
    print(dp[N])


if __name__ == "__main__":
    solve()

