#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 5001;
ll dp[N][N], dp2[N][N]; 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n, k;
        cin >> n >> k;
        ll cnt = 0;
        vector<ll> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i];
        }
        for(i = 0; i <= n; i++){
            dp[i][0] = 1;
            dp2[i][0] = 1;
        }
        if(v[n - 1] <= k){
            dp2[n][v[n - 1]] = 1;
        }
        //cout << dp2[n][v[n - 1]];
        for(i = n - 2; i >= 0; i--){
            for(j = 0; j <= k; j++){
                if(j < v[i]){
                    dp2[i + 1][j] = dp2[i + 2][j];
                } 
                else{
                    dp2[i + 1][j] += dp2[i + 2][j - v[i]];
                    dp2[i + 1][j] = min(1LL, dp2[i + 1][j]);
                }
            }
        }
        //for(i = 1; i <= n; i++){
         //   for(j = 0; j <= k; j++){
         //       cout << dp2[i][j] << " ";
         //   }
        //    cout << endl;
        //}
        dp[0][0] = 1;
        for(i = 0; i < n; i++){
            set<ll> s;
            for(ll s2 = 0; s2 <= k; s2++){
                if(dp2[i + 2][s2]){
                    s.insert(s2);
                }
            }
            s.insert(INF);
            for(j = 0; j <= k; j++){
                dp[(i + 1) % 2][j] = 0;
                if(j < v[i]){
                    dp[(i + 1) % 2][j] = dp[i % 2][j];
                }
                else{
                    dp[(i + 1) % 2][j] += dp[i % 2][j - v[i]];
                }
                dp[(i + 1) % 2][j] = min(1LL, dp[(i + 1) % 2][j]);
            }
            bool flag = false;
            for(ll s1 = 0; s1 < k; s1++){
                if(dp[i % 2][s1]){
                    if(s1 < k && s1 + v[i] >= k){
                        flag = true;
                    }
                }
                if(dp2[i + 2][s1]){
                    if(s1 < k && s1 + v[i] >= k){
                        flag = true;
                    }
                }
                if(dp[i % 2][s1]){
                    ll val = k - s1 - v[i];
                    if(val > 0){
                        auto it = s.lower_bound(val);
                        if(*it < k - s1){
                            flag = true;
                        }
                    }
                }
            }
            if(!flag){
                cnt++;
            }
        }
        cout << cnt;
    }
    return 0;
}

Measured memory_bytes: 219284