K = gets.chomp
D = gets.chomp.to_i
MOD = 10 ** 9 + 7

N = K.size

dp = Array.new(10**5 + 5) { Array.new(101) { Array.new(2, 0) } }

dp[0][0][0] = 1

(0...N).each do |i|
  (0...D).each do |j|
    (0..1).each do |k|
      nd = K[i].to_i
      (0..9).each do |d|
        ni = i + 1
        nj = (j + d) % D
        nk = k
        if k == 0
          next if d > nd
          nk = 1 if d < nd
        end
        dp[ni][nj][nk] += dp[i][j][k]
      end
    end
  end
end

p (dp[N][0][0] + dp[N][0][1] - 1) % MOD
