#include<iostream>
#include<algorithm>
#define endl '\n'
using namespace std;
int s,n,num[2005],dp[20005];
int minim(int sum)
{
    if(sum<0) return 100000000;
    if(sum==0) return 0;
    if(dp[sum]) return dp[sum];

    int res=100000000;

    for(int i=n-1;i>=0;i--)
     res=min(res,minim(sum-num[i])+1);

    return dp[sum]=res;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>s>>n;

    for(int i=0;i<n;i++)
        cin>>num[i];

   // sort(num,num+n);

    cout<<minim(s)<<endl;
}



