import Foundation
let mod = Int(1e9)+7

let k = Array(readLine()!)
let d = Int(readLine()!)!

var dp = [[[Int]]](repeating: [[Int]](repeating: [Int](repeating: -1,
                                                       count: 2),
                                      count: 10010),
                   count: 110)




func dfs(_ cs: Int, _ pos: Int, _ isOnUpper: Bool) -> Int {
    if pos == k.count {
        return cs == 0 ? 1 : 0
    }
    let upperBound = isOnUpper ? Int("\(k[pos])")! : 9
    guard dp[cs][pos][isOnUpper ? 0 : 1] == -1 else {
        return dp[cs][pos][isOnUpper ? 0 : 1]
    }
    
    var res = 0
    for i in stride(from: 0, through: upperBound, by: 1) {
        res += dfs((cs+i)%d, pos+1, isOnUpper && i == upperBound)
        if res >= mod {
            res -= mod
        }
    }
    
    dp[cs][pos][isOnUpper ? 0 : 1] = res
    return res
}

let res = dfs(0,0, true)-1
print(res < 0 ? mod + res : res)
//print(brute(String(k), d))
