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

enum mod = 10L^^9 + 7;

void main() {
    auto k = readln.chomp;
    int n = k.length.to!int;
    int d;
    scan(d);

    auto dp = new long[][][](n + 1, 2, d);
    dp[0][0][0] = 1;

    foreach (i ; 0 .. n) {
        foreach (m ; 0 .. 2) {
            foreach (r ; 0 .. d) {
                foreach (a ; 0 .. (m ? 10 : k[i] - '0' + 1)) {
                    (dp[i+1][m | (a < k[i] - '0')][(r + a % d) % d] += dp[i][m][r]) %= mod;
                }
            }
        }
    }

    auto ans = dp[n][0][0] + dp[n][1][0] - 1 + mod;
    ans %= mod;

    writeln(ans);
}


int LIS(T)(T[] arr) {
    import std.range, std.algorithm;

    auto n = arr.length;
    auto dp = repeat(T.max, n + 1).array.assumeSorted;
    dp[0] = T.min;

    int res;

    foreach (i; 0 .. n) {
        auto j = dp.lowerBound(arr[i]).length;
        dp[j] = arr[i];
        res = max(res, j);
    }

    return res;
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}