#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 30;
int n, m, x, y,q;ll z, w=0, sum = 0, ans = 0;
const int MAX = 510000;
const int MOD = 1000000007;
int dp[10010][2][110];
int main(void) {
	string s; int d; cin >> s >> d;
	Fill(dp, 0);
	dp[0][1][0] = 1;
	rep(i, s.size()) {
		rep(j, d) {
			rep(k, 10) {
				dp[i + 1][0][(j + k) % d] += dp[i][0][j];
				dp[i + 1][0][(j + k) % d] %= MOD;
			}
			int Si = s[i] - '0';
			rep(k, Si) {
				dp[i + 1][0][(j + k) % d] += dp[i][1][j];
				dp[i + 1][0][(j + k) % d] %= MOD;
			}
			dp[i + 1][1][(j + Si) % d] = dp[i][1][j];
		}
	}cout << (dp[s.size()][0][0] + dp[s.size()][1][0] - 1 + MOD) %MOD << endl;
}
#include <bits/stdc++.h>

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 2e5 + 10;
int T;

const int mod = 1e9 + 7;

int d;
char s[10010];
int dp[10010][111];
int len;

int dfs(int pos, int cursum, bool ding)
{
    if (pos == len)
    {
        return cursum == 0;
    }

    if (ding == false && dp[pos][cursum] != -1)
    {
        return dp[pos][cursum];
    }

    int ret = 0;

    int ed = 9;
    if (ding) ed = s[pos] - '0';
    for (int i = 0; i <= ed; i++)
    {
        int v = dfs(pos + 1, (cursum + i) % d, ding && i == ed);
        ret = (ret + v) % mod;
    }

    if (!ding) dp[pos][cursum] = ret;
    return ret;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif

    while (~scanf("%s", s))
    {
        scanf("%d", &d);
        len = strlen(s);

        clr(dp, -1);

        int ans = dfs(0, 0, true);
        ans = (ans - 1 + mod) % mod;
        printf("%d\n", ans);
    }

    return 0;
}
