#include<bits/stdc++.h>
using namespace std ;
int a[105];
bool cmp(int a,int b)
{
	if(a>b) return true;
	else return false;
}
int main() 
{
	int m,n;
	cin>>m>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1,cmp);
	int f=0;
	int flag=0;
	while(f<m)
	{
		flag++;
		f+=a[flag];
	}
	cout<<flag;
	return 0 ;
}

/**************************************************************
	Problem: 1326
	User: chenkexin
	Language: C++
	Result: Wrong Answer
****************************************************************/