// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

const int N = 5010;

bool canleft[N][N], canright[N][N];

int n, K;

int a[N];

bool can[N];

int main(){

	ios::sync_with_stdio(0);

	cin.tie(0), cout.tie(0);

	cin >> n >> K;

	for(int i = 1; i <= n; i++)

		cin >> a[i];

	canleft[0][0] = 1;

	for(int i = 1; i <= n - 1; i++){

		for(int j = 0; j < N; j++){

			canleft[i][j] = canleft[i - 1][j];

			if(j >= a[i])

				canleft[i][j] |= canleft[i - 1][j - a[i]];

		}

	}

	canright[n + 1][0] = 1;

	for(int i = n; i >= 2; i--){

		for(int j = 0; j < N; j++){

			canright[i][j] = canright[i + 1][j];

			if(j >= a[i])

				canright[i][j] |= canright[i + 1][j - a[i]];

		}

	}

	int cnt = 0;

	for(int i = 1; i <= n; i++){

		bool nece = false;

		vector<int> A, B;

		for(int j = 0; j < N; j++)

			if(canleft[i - 1][j]) A.push_back(j);

		for(int j = 0; j < N; j++)

			if(canright[i + 1][j]) B.push_back(j);

		for(int val : A){

			int tmp = K - a[i] - val;

			vector<int>::iterator it = lower_bound(B.begin(), B.end(), tmp);

			if(it != B.end()){

				if((*it) + val < K)

					nece = true;

			}

		}

		if(!nece) cnt++;

	}

	cout << cnt << "\n";

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.1296151502340714x):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<int, pii> pipii;

typedef pair<pii, pii> piipii;



#define mp make_pair

#define fi first

#define se second

#define all(a) (a).begin(), (a).end()

#define sz(a) (int)(a).size()

#define eb emplace_back



int a[5005];

bool pref[5005][5005], suff[5005][5005];

// int sum[5005][5005];

int main(){

    int n, k;

    scanf("%d%d", &n, &k);

    int res = 0;

    for(int i=1;i<=n;i++) scanf("%d", &a[i]), res = min(res+a[i], k);



    pref[0][0] = 1;

    suff[n+1][0] = 1;

    for(int i=1;i<=n;i++){

        for(int j=0;j<=k;j++){

            if(pref[i-1][j]){

                pref[i][min(k, j+a[i])] = 1;

                pref[i][j] = 1;

            }

        }

    }

    for(int i=n;i>=1;i--){

        for(int j=0;j<=k;j++){

            if(suff[i+1][j]){

                suff[i][min(k, j+a[i])] = 1;

                suff[i][j] = 1;

            }

        }

    }



    int ans = 0;

    for(int i=1;i<=n;i++){

        bool ok = 1;



        int sum = 0;

        int ll = k, rr = k-1;

        for(int j=k-1;j>=0;j--){

            if(pref[i-1][j]){

                if(j+a[i] >= k){

                    ok = 0;

                    break;

                }

                int l = k-(j+a[i]);

                int r = k-j-1;



                while(ll > l){

                    ll--;

                    if(suff[i+1][ll]) sum++;

                } 

                while(rr > r){

                    if(suff[i+1][rr]) sum--;

                    rr--;

                }

                if(sum > 0) ok = 0;

                // if(l <= r && sum[i+1][r] - sum[i+1][l-1] > 0) ok = 0;

            }

        }

        for(int j=max(0, k-a[i]);j<=k-1;j++){

            if(pref[i-1][j]) ok = 0;

            if(suff[i+1][j]) ok = 0;

        }

        ans += ok;

    }

    printf("%d\n", ans);

}