#include <stdio.h>

int main(void)
{
    int n, m;
    int c[64];
    int mini[65536];
    int i, j;
    const int MAXIMUM = 1000000;

    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++){
        scanf("%d", &c[i]);
    }

    mini[0] = 0;
    for (i = 1; i <= n; i++){
        mini[i] = MAXIMUM;
    }
    for (i = 0; i < m; i++){
        for (j = 0; j <= n - c[i]; j++){
            if (mini[j + c[i]] > mini[j] + 1){
                mini[j + c[i]] = mini[j] + 1;
            }
        }
    }

    printf("%d\n", mini[n]);

    return (0);
}