def main():
    n,m=map(int,input().split())
    c=list(map(int,input().split()))
    dp=list(range(n+1))
    k=0
    while k<len(c):
        for i in range(n+1-c[k]):
            dp[i+c[k]]=min(dp[i+c[k]],dp[i]+1)
        k+=1
    print(dp[n])

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

if __name__=="__main__":
    main()
