/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp*/

#include<stdio.h>

int main(void){
    int n, m, i, j, min;
    min = 50000;
    
    //??\??????
    int coin[21];
    scanf("%d %d", &n, &m);
    for(i = 1; i < m+1; i++){
        scanf("%d", &coin[i]);
        if(coin[i] == 1){
            coin[1] = j;
            coin[1] = coin[i];
            coin[i] = j;
        }
    }
    //????????????????????????,0?????????MAX?????£??\???0????????????0
    int table[21][50001]={};
    for(i=0;i<n+1;i++){
        table[0][i] = 50000;
    }
    for(i=1;i<m+1;i++){
        for(j=1;j<n+1;j++){
            //table[i][j]????????????
                if(coin[i] > j){//?????¢???n=j??????????????????????????¨??£?????????
                    table[i][j] = table[i-1][j];
                }else{//2????????§min??????????????£?????????
                    if(table[i-1][j] < table[i][j - coin[i]] + 1){
                        table[i][j] = table[i-1][j];
                    }else{
                        table[i][j] = table[i][j - coin[i]] + 1;
                    }
                }
            //printf("%d",table[i][j]);
        }
       // printf("\n");
        if(min > table[i-1][j-1])
            min = table[i-1][j-1];
    }
    printf("%d\n",min);
    return 0;
}