#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

trait Monoid<T>: SemiGroup<T> {
    fn identity() -> T;
}
trait SemiGroup<T>: Magma<T> {}
trait Magma<T> {
    fn operation(lhs: T, rhs: T) -> T;
}
#[derive(Debug)]
struct SegmentTree<T, U> {
    len: usize,
    nodes: Vec<T>,
    phantom: std::marker::PhantomData<U>,
}
impl<T, U> SegmentTree<T, U>
where
    U: Monoid<T>,
    T: Copy + Clone + std::fmt::Debug,
{
#[allow(dead_code)]
    fn new(n: usize) -> Self {
        let mut len = 1;
        while len < n {
            len *= 2;
        }
        SegmentTree {
            len: len,
            nodes: vec![U::identity(); 2 * len - 1],
            phantom: Default::default(),
        }
    }
#[allow(dead_code)]
    fn from_vec(vec: &Vec<T>) -> Self {
        let mut len = 1;
        while len < vec.len() {
            len *= 2;
        }
        let mut nodes = vec![U::identity(); 2 * len - 1];
        for i in 0..vec.len() {
            nodes[i + len - 1] = vec[i];
        }
        for i in (0..len - 1).rev() {
            nodes[i] = U::operation(nodes[2 * i + 1], nodes[2 * i + 2]);
        }
        SegmentTree {
            len: len,
            nodes: nodes,
            phantom: Default::default(),
        }
    }
#[allow(dead_code)]
    fn update(&mut self, index: usize, val: T) {
        let mut index = index;
        index += self.len - 1;
        self.nodes[index] = val;
        while index > 0 {
            index = (index - 1) / 2;
            self.nodes[index] = U::operation(self.nodes[2 * index + 1], self.nodes[2 * index + 2]);
        }
    }
    fn get(&self, l: usize, r: usize) -> T {
        self._get(l, r, 0, 0, self.len)
    }
    fn _get(&self, ql: usize, qr: usize, index: usize, l: usize, r: usize) -> T {
        if r <= ql || qr <= l {
            return U::identity();
        }
        if ql <= l && r <= qr {
            return self.nodes[index];
        }
        let vl = self._get(ql, qr, 2 * index + 1, l, (l + r) / 2);
        let vr = self._get(ql, qr, 2 * index + 2, (l + r) / 2, r);
        U::operation(vl, vr)
    }
}

struct IMonoid;
impl Monoid<usize> for IMonoid {
    fn identity() -> usize {
        0
    }
}
impl Magma<usize> for IMonoid {
    fn operation(lhs: usize, rhs: usize) -> usize {
        max!(lhs,rhs)
    }
}
impl SemiGroup<usize> for IMonoid {}

fn solve() {
    let (n,k) = get!(usize, usize);
    let a = get!([usize]);

    let mut lsum = vec![vec![false;k]; n+1];
    let mut rsum = vec![vec![false;k]; n+1];
    lsum[0][0] = true;
    for i in 0..n {
        for j in 0..k {
            lsum[i+1][j] |= if j<a[i] {
                lsum[i][j]
            } else {
                lsum[i][j]|lsum[i][j-a[i]]
            };
        }
    }
    rsum[n][0] = true;
    for i in (0..n).rev() {
        for j in 0..k {
            rsum[i][j] |= if j<a[i] {
                rsum[i+1][j]
            } else {
                rsum[i+1][j]|rsum[i+1][j-a[i]]
            };
        }
    }

    let mut count = 0usize;
    for i in 0..n {
        let mut tree = SegmentTree::<usize, IMonoid>::new(k);
        for j in 0..k {
            if rsum[i+1][j] {
                tree.update(j,j);
            }
        }
        for j in 0..k {
            if !lsum[i][j] {
                continue;
            }
            let v = j+tree.get(0, k-j);
            if v + a[i] >= k {
                count += 1;
                break;
            }
        }
    }
    println!("{}", n-count);
}


Measured memory_bytes: 59772