Problem:
Score : 600 points

Problem Statement

AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.
Because he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.

Then, for each card i, he judges whether it is unnecessary or not, as follows:

If, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.

Otherwise, card i is NOT unnecessary.

Find the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.

Constraints

All input values are integers.

1≤N≤5000

1≤K≤5000

1≤a_i≤10^9 (1≤i≤N)

Partial Score

300 points will be awarded for passing the test set satisfying N,K≤400.

Input

The input is given from Standard Input in the following format:

N K
a_1 a_2 ... a_N

Output

Print the number of the unnecessary cards.

Sample Input 1

3 6
1 4 3

Sample Output 1

1

There are two good sets: {2,3} and {1,2,3}.

Card 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.

For card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.

Neither is card 3 for a similar reason, hence the answer is 1.

Sample Input 2

5 400
3 1 4 1 5

Sample Output 2

5

In this case, there is no good set. Therefore, all the cards are unnecessary.

Sample Input 3

6 20
10 4 3 10 25 2

Sample Output 3

3

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

/*
aiが不必要である条件

aiを含む任意の総和K以上の部分集合がK+ai以上であるということ

逆に言えば、K-K+ai間ギャップにaiを含む部分集合が存在しないこと

全体和から大きい順に除いていってK以上のぎりぎりにしたとき、
値がギャップにあれば必要、ギャップ以上かそもK未満なら不必要
->最も器用な構成の仕方でギャップにあるかどうか判定することで、
これでギャップに入れられないならその他の構成の仕方では
なおさらギャップに入らないので不必要であろうと考えられる



^-editorialでは
必要である条件に注目していた
必要<-> K-ai~K間の総和をiを使わずに実現できることと捉える
こうすると、考えればよい値域がK以下になるため、値域を含めて
dpを実施できる
dp[i][j] i枚目まで使ったときに総和をjにできるかどうか
*/

//必要ならtrue 不必要ならfalse
bool f(ll i, vector<ll> &a, ll K) {
    if (i >= a.size() || K - a[i] <= 0) return true;
    ll ub = K, lb = K - a[i];
    ll N = a.size();
    vector<ll> b = a; b.erase(b.begin()+i);
    vector<vector<bool> > dp(N,vector<bool>(K+1,false));
    for (int i = 0; i < N; i++) dp[i][0] = true;
    //dp[0][0] = true;
    for (int i = 0; i < N-1; i++) {
        for (int j = 0; j <= K; j++) {
            if (j-b[i] >= 0)
            dp[i+1][j] = dp[i][j] || dp[i][j-b[i]];
        }
    }
    
    /*for (int i = 0; i < N; i++) {
        for (int j = 0; j <= K; j++) {
            cout << dp[i][j] << " ";
        }cout << endl;
    }*/

    bool res = false;
    for (ll k = lb; k < ub; k++) {
        if (dp[N-1][k]) res = true;
    }
    return res;
}

int main() {
    ll N; cin >> N;
    ll K; cin >> K;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll l = 0, r = N;
    //不不不必必必
    while (r - l > 1) {
        ll mid = (r+l)/2;
        if (f(mid,a,K)) r = mid;
        else l = mid;
    }
    cout << l+1 << endl;


}