#import <stdio.h>
#import <stdlib.h>
typedef long long INT;

int compare_int(const void *a, const void *b) {
    return (int)(*(INT*)a - *(INT*)b);
}

int main(int argc, const char * argv[]) {
    int N;
    INT x;
    scanf("%d %lld", &N, &x);
    INT *numbers = (INT*)malloc(N * sizeof(INT));
    
    INT n;
    int i = 0;
    while (scanf("%lld", &n) != EOF) {
        numbers[i] = n;
        i++;
    }
    
    qsort(numbers, N, sizeof(INT), compare_int);
    i=0;
    int count=0;
    while (x>0 && i<N) {
        if (x>=numbers[i]) {
            x -= numbers[i];
            count++;
        } else {
            x=0;
            break;
        }
        i++;
    }
    if (x>0) {
        count--;
    }

    printf("%d", count);
    
    free(numbers);
    return 0;
}
