#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    n, m = iim()
    C = list(iim())

    dp = [n] * (n + 1)
    dp[0] = 0
    for co in C:
        for i in range(co, n+1):
            dp[i] = min(dp[i], dp[i-co] + 1)
    print(dp[n])

if __name__ == "__main__":
    resolve()
 iim = lambda: map(int, input().rstrip().split()) iim lambda: map(int, input().rstrip().split()) map(int, input().rstrip().split()) map int input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split def resolve():
    n, m = iim()
    C = list(iim())

    dp = [n] * (n + 1)
    dp[0] = 0
    for co in C:
        for i in range(co, n+1):
            dp[i] = min(dp[i], dp[i-co] + 1)
    print(dp[n]) resolve n, m = iim() n iim() iim m C = list(iim()) C list(iim()) list iim() iim dp = [n] * (n + 1) dp [n] * (n + 1) [n] n n + 1 n 1 dp[0] = 0 dp[0] dp 0 0 for co in C:
        for i in range(co, n+1):
            dp[i] = min(dp[i], dp[i-co] + 1)
     co C for i in range(co, n+1):
            dp[i] = min(dp[i], dp[i-co] + 1)
     i range(co, n+1) range co n+1 n 1 dp[i] = min(dp[i], dp[i-co] + 1) dp[i] dp i min(dp[i], dp[i-co] + 1) min dp[i] dp i dp[i-co] + 1 dp[i-co] dp i-co i co 1 print(dp[n]) print dp[n] dp n if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    n, m = iim()
    C = list(iim())

    dp = [n] * (n + 1)
    dp[0] = 0
    for co in C:
        for i in range(co, n+1):
            dp[i] = min(dp[i], dp[i-co] + 1)
    print(dp[n]) def resolve():
    n, m = iim()
    C = list(iim())

    dp = [n] * (n + 1)
    dp[0] = 0
    for co in C:
        for i in range(co, n+1):
            dp[i] = min(dp[i], dp[i-co] + 1)
    print(dp[n]) resolve iim = lambda: map(int, input().rstrip().split()) lambda: map(int, input().rstrip().split()) iim
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    n, m = iim()
    C = list(iim())

    dp = [n] * (n + 1)
    dp[0] = 0
    for co in C:
        for i in range(co, n+1):
            dp[i] = min(dp[i], dp[i-co] + 1)
    print(dp[n])

if __name__ == "__main__":
    resolve()

