import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto K = readln.chomp.to!(char[]);
    auto D = readln.chomp.to!long;

    auto DP = new long[][][](2, K.length, D);
    foreach (i, c; K) {
        if (i == 0) {
            foreach (x; 0..c-'0') {
                ++DP[0][i][x % D];
            }
            ++DP[1][i][(c-'0') % D];
        } else {
            foreach (x; 0..D) {
                foreach (y; 0..10) {
                    DP[0][i][(x+y)%D] = (DP[0][i][(x+y)%D] + DP[0][i-1][x]) % P;
                }
                foreach (y; 0..c-'0') {
                    DP[0][i][(x+y)%D] = (DP[0][i][(x+y)%D] + DP[1][i-1][x]) % P;
                }
                DP[1][i][(x+c-'0')%D] = (DP[1][i][(x+c-'0')%D] + DP[1][i-1][x]) % P;
            }
        }
    }
    writeln((DP[1][K.length-1][0] + DP[0][K.length-1][0] - 1));
}