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 factorial(n)
    local a = 1
    for i=1, n do
        a = a * i
    end
    return a
end

local function nCr(n, r)
    if r > n then
        return 0
    end
    if r > n/2 then
        r = n - r
    end
    local a = 1
    for i=n, n-r+1, -1 do
        a = a * i
    end
    return a // factorial(r)
end

local function normal(d, k)
    return nCr(d, k) * math.floor(9^k)
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 function rec(x, remain)
    if remain == 0 then
        return 1
    end
    for i=x, D do
        if T[i] ~= 0 then
            local ans1 = normal(D-i, remain)
            local ans2 = (T[i] - 1) * normal(D-i, remain-1)
            local ans3 = 1 * rec(i+1, remain-1)
            return ans1+ans2+ans3
        end
    end
    return 0
end

local ans = rec(1, K)
print(ans)