#include<iostream>
using namespace std;
int s,n;
int dp[20007][2007];
bool b[20007][2007];
int a[2007];
int f(int sm, int ch)
{
    //cout<<sm<<" "<<ch<<"\n";
    if (sm<0) return 70000;
    if (sm==0) return 0;
    if (ch==n) return 70000;
    if (b[sm][ch])
    {
        return dp[sm][ch];
    }
    b[sm][ch]=true;
    int aa=1+f(sm-a[ch],ch);
    int bb=f(sm,ch+1);
    dp[sm][ch]=min(aa,bb);
    return dp[sm][ch];
}
int main()
{
    cin>>s>>n;
    for (int q=0;q<n;q++) cin>>a[q];
    cout<<f(s,0)<<"\n";
}
