#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 5050
int a[N]= {0};

int  main()
{
    ll n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ll sum =0;
    ll flat;
    for(int i=n; i>=0; i--)
    {
//sum +a[i] < k
        if(sum <k- a[i])
        {
            sum += a[i];
        }
        else
        {
            flat=i;
        }
    }
    cout<<flat<<endl;
    return 0;
}
