/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author rahdirigs
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

template <typename T> void add(T& a, T b, int mod) {
	a += b;
	if (a >= mod)
		a -= mod;
}

template <typename T> void sub(T& a, T b, int mod) {
	a -= b;
	if (a < 0)
		a += mod;
}

const int mxN = 10005, mxD = 110, mod = 1e9 + 7;
ll dp[mxN][mxD][2];

class TaskS {
public:
	string K;
	int D, n;
	vector<int> digits;

	void solve(std::istream& in, std::ostream& out) {
		in >> K >> D;
		for (char it : K) digits.push_back(it - '0');
		n = (int) digits.size();
		memset(dp, -1, sizeof(dp));
		ll ans = rec(0, 0, 1);
		sub(ans, 1ll, mod);
		out << ans;
	}

	ll rec(int pos, int sum, int flag) {
		if (pos == n) {
			if (sum % D == 0) return 1;
			return 0;
		}
		if (dp[pos][sum][flag] != -1) return dp[pos][sum][flag];
		int limit = 9;
		ll tot = 0;
		if (flag == 1) limit = digits[pos];
		for (int i = 0; i <= limit; i++) {
			if (i == digits[pos]) {
				add(tot, rec(pos + 1, (sum + i) % D, flag), mod);
			} else {
				add(tot, rec(pos + 1, (sum + i) % D, 0), mod);
			}
		}
		return dp[pos][sum][flag] = tot;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	TaskS solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define int long long

int dp[10010][110];
int mod = 1e9 + 7;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int d;
	cin >> d;
	int n = s.size();
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            for (int k = 0; k < 10; k++) {
                dp[i + 1][(j + k) % d] += dp[i][j];
                dp[i + 1][(j + k) % d] %= mod;
            }
        }
	}
	int sum = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
        for (int j = 0; j < s[i] - '0'; j++) {
            ans += dp[n - i - 1][(d - (sum + j) % d) % d];
            ans %= mod;
        }
        sum += s[i] - '0';
	}
	if (sum % d == 0) {
        ans++;
	}
	ans += mod - 1;
	ans %= mod;
	cout << ans << endl;
	return 0;
}
