class Integer
  def digit_sum_multiple_count(div, mod = 10 ** 9 + 7)
    s = self.to_s
    l = s.size

    dpA = Array.new(l + 1) { Array.new(div, 0) }
    dpB = Array.new(l + 1) { Array.new(div, 0) }
    dpA[0][0] = 1

    l.times do |i|
      n = s[i].to_i

      0.upto(div - 1) do |j|
        if dpA[i][j] > 0
          dpA[i + 1][(j + n) % div] = dpA[i][j]

          if i > 0
            0.upto(n - 1) do |k|
              dpB[i + 1][(j + k) % div] += 1
            end
          end
        end

        if dpB[i][j] > 0
          0.upto(9) do |k|
            dpB[i + 1][(j + k) % div] += dpB[i][j]
            dpB[i + 1][(j + k) % div] %= mod
          end
        end
      end

      1.upto(9) do |k|
        next if i == 0 && k >= n
        dpB[i + 1][k % div] += 1
      end
    end

    (dpA[l][0] + dpB[l][0]) % mod
  end
end

K = gets.to_i
D = gets.to_i

puts K.digit_sum_multiple_count(D)
