#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define rep(i,n) for(auto i=0;i<n;++i)
#define repr(i,n) for(auto i=n;i>=0;--i)
#define repi(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define repir(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define for(i,a,b) for(auto i=a;i<b;++i)
#define sort(v,n) sort(v, v+n)
#define sortv(v) sort(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define inf 999999999
#define mod 1000000007
#define pb push_back
#define pf push_front
#define mp make_pair
#define sv(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, x;
  scanf("%d %d", &n, &x);

  vector<int> a(n);
  rep(i,n){
    scanf("%d", &a[i]);
  }

  sort(all(a));

  int ans = 0;
  rep(i,n){
    if(i == n - 1){
      if(x == a[i]) ans++;
      break;
    }

    if(x >= a[i]){
      x -= a[i];
      ans++;
    }else{
      break;
    }
  }

  printf("%d\n", ans);
  return 0;
}

