parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	a = parseMap(split(chomp(readline()),""))
	k = readline() |> parseInt
	n = length(a)
	dp = zeros(Int,n,k+1,2)
	dp[1,2,1] = a[1]-1
	dp[1,2,2] = 1
	dp[1,1,1] = 1
	for i in 2:n
		for j in 1:k+1
			dp[i,j,1] += dp[i-1,j,1]+dp[i-1,j,2]
			if a[i] == 0
				dp[i,j,2] = dp[i-1,j,2]
			else
				dp[i,j,2] = 0
			end
			if j>1
				dp[i,j,1] += dp[i-1,j-1,1]*9+dp[i-1,j-1,2]*(max(a[i]-1,0))
				if a[i]>0
					dp[i,j,2] = dp[i-1,j-1,2]
				else
					dp[i,j,2] = 0
				end
			end
		end
	end
	println(dp[n,k+1,1]+dp[n,k+1,2])
end

main()