#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 5005
#define pll pair<ll,ll>

ll dp[N][N];

bool evaluate(vector<pll> &vt, ll idx, ll k){
	ll n = vt.size();
	memset(dp, 0, sizeof(dp));
	dp[0][0]=1;
	
	for(int i=0 ; i<n ; i++) { 
		for(int cur_sum = 0 ; cur_sum <=k ; cur_sum++){
			
			dp[i+1][cur_sum] = dp[i][cur_sum];
			
			ll cur = vt[i].first;
			if(cur <= cur_sum && i != idx){
				dp[i+1][cur_sum] |= dp[i][cur_sum-cur];
			}
			
		}
	}

	for(int i = max(0ll, k-vt[idx].first) ; i<= k-1 ; i++){
		if(dp[n][i]){
			return true;
		}
	}
	
	return false;
}

ll subset_sum(vector<pll> &vt, ll k){
	ll n = vt.size();
	ll s = 0;
	ll e = n-1;
	ll ans = -1;
	
	while(s<=e){
		ll mid = (s+e)/2;
		if(evaluate(vt, mid, k)==0){
			ans = mid;
			s = mid+1;
		} else {
			e = mid-1;
		}
	}
	return ans;
}


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
	ll n, k;
	cin>>n>>k;
	vector<pll> a(n);
	for(ll i=0 ; i<n ; i++){
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a.begin(), a.end());
	ll val = subset_sum(a, k);
	cout<<val+1;
	return 0;
}