N = gets.chomp.split("").map(&:to_i)
D = gets.to_i
n = N.size-1
ans = 0
dp = Array.new(n).map{Array.new(D,0)}
(0..9).each do |i|
  dp[0][i%D] += 1
end
(n-1).times do |i|
  dp[i].each_with_index do |v,j|
    10.times do |k|
      l = (j+k)%D
      dp[i+1][l] += v
    end
  end
  for j in 0..D-1
    dp[i+1][j] %= 10**9+7
  end
end
stack = 0
N.reverse!
n.downto(1) do |i|
  for j in 0..N[i]-1
    ans += dp[i-1][(D-stack-j)%D]
  end
  ans %= 10**9+7
  stack += N[i]
end
stack += N[0]
for i in 0..N[0]
  if (stack+i)%D == 0
    ans += 1
  end
end
p (ans-1)%(10**9+7)