#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const int maxn=5000+10;
int a[maxn];
int n;
int k;
int num;
int x;
int ans=1;
int sum;
int main()
{
	scanf("%d%d",&n,&k);
	num=n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(x>=k)num--;
		else a[ans++]=x;
	}
	ans--;
	sort(a+1,a+num+1);
	while(num>=2)
	{
		sum+=a[num];
		if(a[num-1]+sum<k)
		{
			num--;
			continue;
		}
		if(a[1]+sum>=k)
		{
			ans=0;
			break;
		}
		int l=1,r=num-2;
		while(l+1<r)
		{
			int mid=(l+r)/2;
			if(sum+a[mid]>=k) r=mid;
			else l=mid;
		}
		ans=ans-(num-r);
		num=r;
	}
	printf("%d\n",ans);
	return 0;
}