// Slower C++ solution:
/**

 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏

 *    created : 2020-01-02 16:34:40

**/



#include <iostream>

#include <deque>

#include <map>

#include <queue>

#include <set>

#include <stack>

#include <string>

#include <vector>

#include <algorithm>

#include <cmath>

#include <complex>

#include <numeric>

#include <bitset>

#include <cassert>

#include <cctype>

#include <iomanip>

#include <random>

#include <utility>

#include <chrono>



using namespace std;



using int64 = long long;



template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }

template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }



#ifdef LOCAL

#define debug(_) cerr << #_ << ": " << (_) << '\n'

#else

#define debug(_) 1728

#endif



bool dp1[5050][5050];

bool dp2[5050][5050];



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);



  int n, k; cin >> n >> k;

  vector<int> a(n); cin >> a;



  dp1[0][0] = 1;



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

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

      if (dp1[i][j]) dp1[i + 1][j] = 1;

      if (j + a[i] > 5010) continue;

      dp1[i + 1][j + a[i]] |= dp1[i][j];

    }

  }



  dp2[0][0] = 1;



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

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

      if(dp2[i][j]) dp2[i + 1][j] = 1;

      if (j + a[n - 1 - i] > 5010) continue;

      dp2[i + 1][j + a[n - 1 - i]] |= dp2[i][j];

    }

  }

/*

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

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

      cerr << dp1[i][j] << " ";

    }

    cerr << '\n';

  }



  cerr << '\n';



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

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

      cerr << dp2[i][j] << " ";

    }

    cerr << '\n';

  }

*/

  int need = 0;



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

    int target = max(0, k - a[i - 1]);

    for (int j = target; j <= k - 1; ++j) {

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

        if (dp1[i - 1][l] && dp2[n - i][j - l]) {

          ++need;

          j = l = k + 5;

        }

      }

    }

  }



  cout << n - need << endl;



  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.219434804482843x):
#pragma GCC optimize("unroll-loops")



#include <cstdio>

#include <vector>



using namespace std;



using int64 = long long;



bool dp1[5050][5050];

bool dp2[5050][5050];



template<class T> inline void fastin(T &num) {

  T c;

  num = 0;

  c = getchar_unlocked();

  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;

}



int main() {

  int n, k; fastin(n); fastin(k);

  int a[n];

  for (int i = 0; i < n; ++i) fastin(a[i]);



  dp1[0][0] = 1;



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

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

      if (dp1[i][j]) dp1[i + 1][j] = 1;

      if (j + a[i] > 5000) continue;

      dp1[i + 1][j + a[i]] |= dp1[i][j];

    }

  }



  dp2[0][0] = 1;



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

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

      if(dp2[i][j]) dp2[i + 1][j] = 1;

      if (j + a[n - 1 - i] > 5000) continue;

      dp2[i + 1][j + a[n - 1 - i]] |= dp2[i][j];

    }

  }



  int need = 0;



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

    int target = max(0, k - a[i - 1]);

    for (int j = target; j <= k - 1; ++j) {

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

        if (dp1[i - 1][l] && dp2[n - i][j - l]) {

          ++need;

          j = l = k + 5;

        }

      }

    }

  }



  printf("%d\n", n - need);



  return 0;

}