#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define M 1000000010
int n , N[M] , sum , ans;
int main(){
//    freopen("c1.txt" , "r" , stdin);
    scanf("%d%d" , &n , &sum);
    for (int i = 1 ; i <= n ; ++i){
        scanf("%d" , N + i);
    } 
    sort (N + 1 , N + 1 + n);
    for (int i = 1 ; i <= n ; ++i){
        if (sum < N[i]) break;
        else{
             sum -= N[i];
             ans = i;
        }
    }
    printf ("%d" , ans);
    return 0;
}
