#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, x, res = 0;
    cin >> N >> x;

    int a[N];

    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    sort(a, a+N);

    for (int j = 0; j < N; j++) {
        if (j == N -1) {
            if (x == a[j]) {
                res++;
            }
            break;
        }
        if (x - a[j] >= 0) {
            x -= a[j];
            res++;
        }
    }

    cout << res << endl;
}
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
  int n;
  cin >> n;
  ll x,a[n+1];
  cin >> x;
  rep (i,n){
    cin >> a[i];
  }
  int res = 0;
  sort (a,a+n);
  rep (i,n){
    if (x >= a[i]) {
      res ++;
      x -= a[i];
    }
    else break;
  }
  if (res == n && x) --res;
  cout << res << endl;
}