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.T = function(T) local t={} for i=1,T 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
-- 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 tbl = create_ndim_array(3, {__index = function() return 0 end})
tbl[0][true][0] = 1
for i=0,D-1 do
    for _, m in ipairs {false, true} do
        for k=0,K do
            if tbl[i][m][k] == 0 then
                goto continue_k
            end
            local ni = i+1
            local nd = T[ni]
            for d=0,9 do
                local nk = k
                local nm
                if m == false then
                    nm = false
                else
                    if d > nd then
                        break
                    elseif d == nd then
                        nm = true
                    else
                        nm = false
                    end
                end
                if d ~= 0 then
                    nk = nk + 1
                end
                if nk > K then
                    goto continue_d
                end
                tbl[ni][nm][nk] = tbl[ni][nm][nk] + tbl[i][m][k]
                ::continue_d::
            end
            ::continue_k::
        end
    end
end
local ans = tbl[D][false][K] + tbl[D][true][K]
print(ans)