# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << "\n";
#else
#define DEBUG(message)
#endif

struct Solver {
  void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<vector<bool>> dp_pref(n + 1, vector<bool>(k + 1, false));
    vector<vector<bool>> dp_suf(n + 2, vector<bool>(k + 2, false));

    dp_pref[0][0] = true;
    for (int i = 0; i < n; i++) {
      for (int s = k; s >= 0; s--) {
        if (!dp_pref[i][s]) {
          continue;
        }
        dp_pref[i + 1][s] = true;
        dp_pref[i + 1][min(s + a[i], k)] = true;
      }
    }

    dp_suf[n][0] = true;
    for (int i = n - 1; i >= 0; i--) {
      dp_suf[i][0] = true;
      for (int s = k; s >= 0; s--) {
        if (!dp_suf[i + 1][s]) {
          continue;
        }
        dp_suf[i][s] = true;
        dp_suf[i][min(s + a[i], k)] = true;
      }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
      vector<int> max_index(k);
      for (int j = 0; j < k; j++) {
        if (dp_suf[i + 1][j]) {
          max_index[j] = j;
        } else {
          max_index[j] = max_index[j - 1];
        }
      }

      for (int j = 0; j < k; j++) {
        if (!dp_pref[i][j]) {
          continue;
        }
        int l = max_index[k - 1 - j];
        CHECK(dp_suf[i + 1][l]);
        CHECK(j + l < k);
        if (a[i] + j + l >= k) {
//          cout << i << " " << j << " " << l << endl;
          ++ans;
          break;
        }
      }
    }

    cout << n - ans << "\n";
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    Solver().solve();
  }
  return 0;
}

Measured memory_bytes: 6912