//A-Candy_Distribution_Again
#include <iostream>
#include <algorithm>
using namespace std;

void swap(int*,int*);

int main()
{
  int i,j,n;
  long long int x;
  cin>>n>>x;
  int *a;
  a = new long long int[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }

  int min=a[0];
  j=1;
  for(i=1;i<n;i++){
    
    for(j=i;j<n;j++){
      if(min>a[j]){
        min=a[j];
        swap(&a[i-1],&a[j]);
      }
    }
    
  }

  for(i=0;i<n;i++){
    if(x-a[i]>= 0) x-=*(a +i);
    else break;
  }

  cout<<i<<endl;
  delete [] a;

  return 0;
}

void swap(int *a,int *b){
  int *c;
  c = b;
  b=a;
  a=c;
    }
