K = gets.chomp
D = gets.to_i
KL = K.length
dp = [0]*D
MOD = 10 ** 9 + 7
K[0].to_i.times do |k|
	dp[k%D] += 1
end
tm = K[0].to_i % D
1.upto(KL-1) do |i|
	dg = K[i].to_i
	prev = dp.dup
	dp = [0]*D
	D.times do |j|
		10.times do |k|
			dp[j] += prev[(j-k)%D]
		end
	  dp[j] %= MOD
	end
	dg.times do |k|
		dp[(tm+k)%D] += 1
	end
	tm = (tm+dg) % D
end
dp[tm] += 1
p (dp[0]-1) % MOD