local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
----
local function create_ndim_array(n, last_metatbl)
    local metatables = {}
    metatables[1] = last_metatbl
    for i=2,n do
        metatables[i] = {__index = function(parent, k)
            local child = setmetatable({}, metatables[i-1])
            rawset(parent, k, child)
            return child
        end}
    end
    return setmetatable({}, metatables[n])
end
local function carprod(seqs)
    return coroutine.wrap(function()
        if #seqs == 0 then
            coroutine.yield({})
            return
        end
        local s1 = seqs[1]
        for _,v in ipairs(s1) do
            for t in carprod({select(2, table.unpack(seqs))}) do
                coroutine.yield({v, table.unpack(t)})
            end
        end
    end)
end
-- E
local S = read.l():totable()
local T = {}
for i=1,#S do
    T[i] = tonumber(S[i])
end
local D = #T
local K = read.n()

local set = {{}, {false, true}, {}}
for i=1, D do
    set[1][i] = i
end
for i=0, K do
    table.insert(set[3], i)
end

local tbl = create_ndim_array(3, {__index = function() return 0 end})
tbl[0][true][0] = 1
for ss in carprod(set) do
    local ni, nm, nk = table.unpack(ss)
    for d=0,9 do
        local nd = T[ni]
        if nm then
            local source = tbl[ni-1][true]
            if d == nd then
                if d == 0 then
                    tbl[ni][nm][nk] = tbl[ni][nm][nk] + source[nk]
                else
                    tbl[ni][nm][nk] = tbl[ni][nm][nk] + source[nk-1]
                end
            else
                -- can't let nm == true
            end
        else
            if d >= nd then
                local source = tbl[ni-1][false]
                if d == 0 then
                    tbl[ni][nm][nk] = tbl[ni][nm][nk] + source[nk]
                else
                    tbl[ni][nm][nk] = tbl[ni][nm][nk] + source[nk-1]
                end
            else -- d < nd
                local source1 = tbl[ni-1][true]
                local source2 = tbl[ni-1][false]
                if d == 0 then
                    tbl[ni][nm][nk] = tbl[ni][nm][nk] + source1[nk] + source2[nk]
                else
                    tbl[ni][nm][nk] = tbl[ni][nm][nk] + source1[nk-1] + source2[nk-1]
                end
            end
        end
    end
end
local ans = tbl[D][false][K] + tbl[D][true][K]
print(ans)