import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto K = readln.chomp;
    auto D = readln.chomp.to!int;
    auto N = K.length.to!int;

    auto dp = new long[][][](N+1, D, 2);
    dp[0][0][0] = 1;

    foreach (i; 0..N) {
        foreach (j; 0..D) {
            foreach (k; 0..2) {
                int d = 10;
                if (!k) d = K[i] - '0' + 1;
                foreach (x; 0..d) {
                    (dp[i+1][(j+x)%D][k||x<K[i]-'0'] += dp[i][j][k]) %= MOD;
                }
            }
        }
    }

    long ans = (dp[N][0][0] + dp[N][0][1] - 1) % MOD;
    ans = (ans + MOD) % MOD;
    ans.writeln;
}
