#include<cstdio>#include<iostream>#include<cstring>#include<vector>usingnamespace std;constint N =32;constint M =128;constint MAX =0x3f3f3f3f;int w[N];intmain(){int m, n;scanf("%d %d",&m,&n);memset(w,0,sizeof w);
vector<vector<int>>f(n+1, vector<int>(m+1, MAX));for(int i =1; i <= n; i++){scanf("%d",&w[i]);}for(int i =0; i <= n; i++) f[i][0]=0;for(int i =1; i <= n; i++){for(int j =0; j <= m; j++){if(j >= w[i]) f[i][j]=min(f[i-1][j],f[i-1][j-w[i]]+1);else f[i][j]= f[i-1][j];}}if(f[n][m]==MAX){
cout<<0<<endl;}else{
cout<<f[n][m]<<endl;}return0;}