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 array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local MOD = math.floor(10^9) + 7
local S = read.l():totable()
local K = read.n()
local tbl = array(3, 0)
local FIT = 0
local SMALLER = 1
tbl[0][FIT][0] = 1

for i=1,#S do
    -- decide tbl[i] from tbl[i-1]
    local constraint_digit = tonumber(S[i])
    local oldtbl = tbl[i-1]
    local newtbl = tbl[i]
    local function has_transition(oldfs, newfs, oldk, newk, newd)
        -- Specific to this problem --
        if newd == 0 then
            if newk ~= oldk then
                return false
            end
        else
            if newk ~= oldk + 1 then
                return false
            end
        end
        -- Boiler plate code for digit DP --
        local new_digit = newd
        if oldfs == FIT and newfs == FIT then
            return new_digit == constraint_digit
        elseif oldfs == FIT and newfs == SMALLER then
            return new_digit < constraint_digit
        elseif oldfs == SMALLER and newfs == FIT then
            return false
        elseif oldfs == SMALLER and newfs == SMALLER then
            return true
        end
    end
    local function do_transition(oldfs, newfs, oldk, newk)
        local v = oldtbl[oldfs][oldk]
        newtbl[newfs][newk] = (newtbl[newfs][newk] + v) % MOD
    end
    for oldk=0,3 do
        local newk_start = math.max(0, oldk-1)
        local newk_end = math.min(3, oldk+1)
        for newk=newk_start,newk_end do
            for oldfs=0,1 do
                for newfs=0,1 do
                    for newd=0,9 do
                        if has_transition(oldfs, newfs, oldk, newk, newd) then
                            do_transition(oldfs, newfs, oldk, newk)
                        end
                    end
                end
            end
        end
    end
end
local ans = (tbl[#S][FIT][K] + tbl[#S][SMALLER][K]) % MOD
print(ans)