#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int,vector<int>,greater<int>> que;


llint n,x;
llint a[1000000005];

void solve(){
	cin >> n >> x;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;i++){
		if(i==n-1){
			if(x==a[i])ans++;
			break;
		}
		if(x>=a[i]){
			x-=a[i];
			ans++;
			}
		}
		cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}
