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