#include <stdio.h>
#include <algorithm>

int N,x,a[100];
int main(){
        scanf("%d %d",&N,&x);
        for(int i = 0; i < N; i++) scanf("%d",a+i);
        std::sort(a,a+N);
        
        int c = 0;
        while(c < N && x >= a[c] )  x -= a[c++];
            
  		printf("%d\n",(c == N && x > 0)? N-1:c);        
}