#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define NMAX    50000
#define MMAX    20
#define MAX     1000000000

int *c;
int memo[MMAX][NMAX + 1];

int min2(int x, int y) {

    return x < y ? x : y;
}

// 0???m?¨????????????????????????£???n??????????????¨??????????????????????°?????????°???
int dp(int m, int n) {
    int rep;

    if( m < 0 ) return MAX;
    if( memo[m][n] < MAX ) return memo[m][n];

    if( n == 0 ) {
        rep = 0;
    } else if( n < c[m] ) {
        rep = dp(m - 1, n);
    } else {
        rep = min2(dp(m - 1, n), dp(m, n - c[m]) + 1);
    }
    
    return memo[m][n] = rep;
}

void insertsort(int *a, int n) {
    int i, j;

    for( i = 1; i < n; i++ ) {
        int tmp = a[i];
        for( j = i; j > 0 && a[j - 1] > tmp; j-- ) {
            a[j] = a[j - 1];
        }
        a[j] = tmp;
    }

    return;
}

int main(void) {
    int n, m;
    int i, j;

    scanf("%d %d", &n, &m);
    c = (int *)malloc(sizeof(int) * m);
    for( i = 0; i < m; i++ ) {
        scanf("%d", c + i);
        for( j = 0; j <= NMAX; j++ ) {
            memo[i][j] = MAX;
        }
    }
    insertsort(c, m);

    printf("%d\n", dp(m - 1, n));

    free(c);

    return 0;
}