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: Accepted)

#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 5005
#define M 2000005
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define FJ(i,a,b) for(int i=a;i<b;++i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _q fd[rt]
#define _l fd[rt << 1]
#define _r fd[rt << 1 | 1]
#define MID int mid=((l+r)>>1)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define zero(x) (((x)>0?(x):-(x))<EPS)
#define PB push_back
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define MP make_pair
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;
int n, k;
int a[N];
bool f[2][5005];
bool g[2][5005];
int l[5005][5005];
int r[5005][5005];
int main(){
    //IN;
    SCC(n, k);
    int big = 0;
    int num = 0;
    FF(i, 1, n){
        SC(a[++num]);
        if(a[i] >= k){
            ++big;
            --num;
        }
    }
    f[0][0] = 1;
    int cur = 1;
    FF(i, 1, num){
        FF(j, 0, k - a[i]){
            if(f[cur ^ 1][j])f[cur][j + a[i]] = 1;
        }
        FF(j, 0, k)if(f[cur ^ 1][j])f[cur][j] = 1;
        FF(j, 0, k)l[i][j] = l[i][j - 1] + f[cur][j];
        cur ^= 1;
    }
    g[0][0] = 1;
    cur = 1;
    RR(i, num, 1){
        FF(j, 0, k - a[i]){
            if(g[cur ^ 1][j])g[cur][j + a[i]] = 1;
        }
        FF(j, 0, k)if(g[cur ^ 1][j])g[cur][j] = 1;
        FF(j, 0, k)r[i][j] = r[i][j - 1] + g[cur][j];
        cur ^= 1;
    }
    FF(i, 1, num){
        bool ok = 0;
        //FF(j, k - a[i], k - 1){
        FF(j, 0, k - 1){
            if(j == 0 || l[i - 1][j] > l[i - 1][j - 1]){
                int L = k - a[i] - j, R = k - 1 -j;
                if(L <= 0 || r[i + 1][R] > r[i + 1][L - 1]){
                    ok = 1;
                    break;
                }
            }
        }
        if(ok)++big;
    }
    PR(n - big);
return 0;
}