#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,x,k = 0,sum = 0,ksum = 0;
  long long a[3000];
  cin >> n >> x;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  sort(a,a+n);
  if(sum == x){
    cout << n << endl;
    return 0;
  }
  while(ksum + a[k] <= x && k < n - 1){
    ksum += a[k];
    k++;
  }
  if(x > 0 && k = n - 1)k--;
  cout << k << endl;
  return 0;
}