#include <stdio.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
const ll MOD = 1000000007;

int dp[25][50101] = {0};
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int c[25];
    rep(i, m) scanf("%d", &c[i]);

    rep(j, n+1) dp[0][j] = MOD;
    rep(i, m+1) dp[i][0] = 0;
    rep(i, m){
        rep(j, n+1){
            dp[i+1][j] = dp[i][j];
            if(j - c[i] >= 0){
                dp[i+1][j] = min(dp[i+1][j], dp[i][j-c[i]] + 1);
                dp[i+1][j] = min(dp[i+1][j], dp[i+1][j-c[i]] + 1);
            }
        }
    }

    printf("%d\n", dp[m][n]);
}
