#include <stdio.h>

#define min(x, y)   ((x) < (y) ? (x) : (y))

int main(void) {
    int n, m;
    int dp[50001];
    int coin[20];
    int i, j;

    scanf("%d %d", &n, &m);
    for( i = 0; i < m; i++ ) {
        scanf("%d", coin + i);
    }
    dp[0] = 0;
    for( i = 1; i <= 50000; i++ ) {
        dp[i] = 1 << 20;
    }

    for( i = 0; i < n; i++ ) {
        for( j = 0; j < m; j++ ) {
            if( i + coin[j] <= n ) {
                dp[i + coin[j]] = min(dp[i + coin[j]], dp[i] + 1);
            }
        }
    }

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

    return 0;
}