local mmi = math.min
local mma = math.max
local mce, mfl = math.ceil, math.floor
local n, k = io.read("*n", "*n")
local a = {}
for i = 1, n do
  local at = io.read("*n")
  if at < k then
    table.insert(a, at)
  end
end
n = #a
local function solve()
  if n == 0 then return 0 end
  local tail = {}
  for i = 1, n do
    tail[i] = {}
    for j = 1, mce((k - 1) / 2) do
      tail[i][j] = 0
    end
  end
  local function gettail(i, j)
    if j % 2 == 1 then
      return tail[i][mce(j / 2)] % 2 == 1
    else
      return mfl(tail[i][mce(j / 2)] / 2) == 1
    end
  end
  local function settail(i, j)
    if gettail(i, j) then return end
    local jidx = mce(j / 2)
    tail[i][jidx] = tail[i][jidx] + 2 - (j % 2)
  end
  local curmax = 0
  for i = n, 1, -1 do
    for j = 1, curmax do
      if gettail(i + 1, j) then
        settail(i, j)
        if j + a[i] < k then
          settail(i, j + a[i])
        end
      end
    end
    curmax = mmi(curmax + a[i], k - 1)
    settail(i, a[i])
  end
  local head = {}
  for i = 1, k - 1 do
    head[i] = false
  end
  local cnt = 0
  curmax = 0
  for i = 1, n - 1 do
    local ai = a[i]
    local need = false
    for j = k - ai, k - 1 do
      for p = 1, j - 1 do
        local q = j - p
        if head[p] and gettail(i + 1, q) then
          need = true
          break
        end
      end
      if head[j] or gettail(i + 1, j) then
        need = true
      end
      if need then break end
    end
    if not need then cnt = cnt + 1 end
    for j = mmi(curmax, k - 1 - ai), 1, -1 do
      if head[j] then head[j + ai] = true end
    end
    head[ai] = true
    curmax = mmi(curmax + ai, k - 1)
  end
  do -- i == n
    local ai = a[n]
    local need = false
    for j = k - ai, k - 1 do
      if head[j] then
        need = true
        break
      end
    end
    if not need then cnt = cnt + 1 end
  end
  return cnt
end
print(solve())
