var K = readLine()!
let D = Int(readLine()!)!

var dp = Array(repeating: [true: 0, false: 0], count: D)
dp[0][false] = 1

for _ in stride(from: 0, to: K.count, by: 1) {
    let number = Int(String(K.removeFirst()))!
    var newDP = Array(repeating: [true: 0, false: 0], count: D)

    for i in stride(from: 0, to: D, by: 1) {
        [false, true].forEach { isLessThanK in
            let limit = isLessThanK ? 9 : number
            for j in stride(from: 0, through: limit, by: 1) {
                let newI = (i + j) % D
                let newIsLessThanK = isLessThanK || j < number
                newDP[newI][newIsLessThanK] = (newDP[newI][newIsLessThanK]! + dp[i][isLessThanK]!) % 1_000_000_007
            }
        }
    }

    dp = newDP
}

print((dp[0][true]! + dp[0][false]! + 1_000_000_007 - 1) % 1_000_000_007)
