#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int a[N],n,x;
signed main(){
	scanf("%lld%lld",&n,&x);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	int ans=0;
	for (int i=1;i<=n;i++){
		if (x>=a[i])ans++;
		x-=min(x,a[i]);
	}
	ans-=x>0;
	printf("%lld\n",ans);
}