#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};




int N, K;
vector<int> a;
const int MAX_SIZE = 5005;
int memo[MAX_SIZE][MAX_SIZE];


bool useful(vector<int> &b, int val){
    
    if (b[0] <=K){
        memo[0][b[0]] = 1;
    }
    
    for(auto i = 1; i<N-1; i++){
        for(auto j = 0; j<=K; j++){
            if (b[i] <=K) memo[i][b[i]] = 1;
            memo[i][j] |= memo[i-1][j];
            if (j-b[i]>=0){
                memo[i][j] |= memo[i-1][j-b[i]];
            }
            
    
        }
    }
    
    bool flag = false;
    
    for(auto i = max(0,K-val); i<K; i++){
        
        if (memo[N-2][i] != 0) flag = true;
        
    }
    
    return flag;
}

int main() {
    cin >> N >> K;
    a.resize(N);
    
    for(auto i = 0; i<N;i++){
        
        cin >> a[i];
        
    }
    
    sort(all(a));
    
    if (N == 1){
        cout << 0 << endl;
        return 0;
    }
    
    
    int k = 0;
    
    while(a[k]<K && k != N) {
        k++;
    }
    
    N = k;
    
//    int count = 0;
//    while(count != N){
//        for(auto i = 0; i <N; i++){
//            for(auto j = 0; j<=K; j++){
//                memo[i][j] =0;
//            }
//        }
//        vector<int> b(a);
//        b.erase(find(all(b),a[count]));
//
//        if (useful(b,a[count])) break;
//        count++;
//    }
//
//    cout << count << endl;

    int left = 0;
    int right = N;
    int middle = N/2;

    while(left < right){


        for(auto i = 0; i <N; i++){
            for(auto j = 0; j<=K; j++){
                memo[i][j] =0;
            }
        }

        middle = (left + right)/2;

        vector<int> b(a);
        b.erase(find(all(b),a[middle]));


        if (!useful(b,a[middle])){
            left = middle+1;
        }else{
            right = middle;
        }

    }



    cout << left << endl;


    
    return 0;
}










Measured memory_bytes: 98048