#include<stdio.h>
#include<algorithm>
using namespace std;
__int64 a[606];
bool judge(__int64 a,__int64 b) {
return a>b;
}
int main() {
__int64 n,m;
while(scanf("%I64d %I64d",&n,&m)!=EOF) {
__int64 t=0,mark,l;
for(l=0; l<m; l++) {
scanf("%I64d",&a[l]);
}
sort(a,a+m,judge);
for(l=0; l<m; l++) {
t=t+a[l];
if(t>=n)
break;
}
if(l<m)
printf("%I64d\n",l+1);
else
printf("impossible\n");
}
return 0;
}