#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,x,a[maxn],F;

int main()
{
	n=read(); x=read(); rep(i,1,n) a[i]=read(); sort(a+1,a+n+1);
	ll tmp=0;
	rep(i,1,n)
	{
		tmp+=a[i];
		if(tmp==x) {F=1; cout<<i<<endl; break;}
		else if(tmp>x) {F=1; cout<<i-1<<endl; break;}
	}
	if(!F) cout<<n-1<<endl;
	return 0;
}
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int gcd(int a,int b){
   if(a%b==0) return b;
   return gcd(b,a%b);
}
int digit(int num){
   int cnt=0;
   while(num!=0){
      cnt+=num%10;
      num=num/10;
   }
   return cnt;
}
int main(void){
   int N;
   cin>>N;
   long long x;
   cin>>x;
   vector<long long> a(N);
   vector<long long> result(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   sort(a.begin(),a.end());
   for(int i=0;i<N;i++){
      result[i]=min(x,a[i]);
      x-=result[i];
   }
   result[N-1]+=x;
   int ans=0;
   for(int i=0;i<N;i++){
      if(result[i]==a[i]) ans++;
   }
   cout<<ans<<endl;
   return 0;
}
