#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll

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


