/// > N以下の正整数であって、
var N = readLine()!
/// > 十進法表記したときの各桁の数の和がDの倍数
let D = Int(readLine()!)!


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

/// 先頭からi桁目までの
for _ in stride(from: 0, to: N.count, by: 1) {
    let number = Int(String(N.removeFirst()))!
    var newDP = Array(repeating: [true: 0, false: 0], count: D)

    /// 各桁の数の和が% Dでjとなるものの個数
    for j in stride(from: 0, to: D, by: 1) {
        [false, true].forEach { isLessThanN in
            let limit = isLessThanN ? 9 : number
            for k in stride(from: 0, through: limit, by: 1) {
                let newJ = (j + k) % D
                let newIsLessThanN = isLessThanN || k < number
                newDP[newJ][newIsLessThanN] = (newDP[newJ][newIsLessThanN]! + dp[j][isLessThanN]!) % 1_000_000_007
            }
        }
    }

    dp = newDP
}

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