function string.split(str, separator)
  local ans = {}
  local add_str = str .. separator
  local left = 1
  while left <= #add_str do
    local right = string.find(string.sub(add_str, left, #add_str), separator)
    right = right + left - 1
    table.insert(ans, string.sub(add_str, left, right - 1))
    left = right + 1
  end
  return ans
end

function table.sub(arr, i, j)
  local ans = {}
  for k = i, j do
    table.insert(ans, arr[k])
  end
  return ans
end

function table.concattable(...)
  local arrs = {...}
  local ans = {}
  for i = 1, #arrs do
    for j = 1, #arrs[i] do
      table.insert(ans, arrs[i][j])
    end
  end
  return ans
end

function table.binarysearch(arr, k)
  local left = 1
  local right = #arr
  while left <= right do
    local memo = {}
    for i = 1, #arr - 1 do
      table.insert(memo, {})
    end

    local mid = left + math.floor((right - left)/2)
    if dp(1, k, table.concattable(table.sub(arr, 1, mid - 1), table.sub(arr, mid + 1, #arr)), memo) >= k - arr[mid] then
      right = mid - 1
    else
      left = mid + 1
    end
  end
  return left
end

function dp(i, max, arr, memo)
  if i > #arr then
    return 0
  elseif memo[i][max] then
    return memo[i][max]
  else
    if arr[i] >= max then
      memo[i][max] = dp(i + 1, max, arr, memo)
      return memo[i][max]
    else
      local val1 = arr[i] + dp(i + 1, max - arr[i], arr, memo)
      local val2 = dp(i + 1, max, arr, memo)
      if val1 <= val2 then
        memo[i][max] = val2
        return val2
      else
        memo[i][max] = val1
        return val1
      end
    end
  end
end

function main()
  local input = string.split(io.read(), " ")
  local n = tonumber(input[1])
  local k = tonumber(input[2])
  local a = string.split(io.read(), " ")
  for i = 1, #a do
    a[i] = tonumber(a[i])
  end
  table.sort(a)

  print(table.binarysearch(a, k) - 1)
end

main()
