#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x, count=0;
  cin >> N >> x;
  vector<int> a(N);
  REP(i,N) {
    cin >> a[i];
    sum+=a[i];
  }
  sort ALL(a);
  if(x>sum) count--;
  REP(i,N) {
    if(a[i]<=x) {
      x-=a[i];
      count++;
    }
    if(i==N-1 && 0<x) count--;
    else break;
  }
  cout << count << endl;
}