
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define fo(i, n) for(ll i = 0; i < n; i++)
#define endl "\n"
#define of(i, n) for(ll i = n - 1; i >= 0; i--)
#define ll long long
#define vec vector<ll>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define rep(i,j,n) for (ll i = j; i <= n; ++i)
#define EB emplace_back
#define mem(i,j) memset( i, j,sizeof(i))
#define ff first
#define ss second
#define ii pair<ll,ll>
#define iii pair<ll,pair<ll,ll> >
#define pb push_back
#define mp make_pair
#define all(i) i.begin(),i.end()
#define pr(a) cout<<a<<endl
#define pr
#define prv(a) for(int jkl=0; jkl<a.size();jkl++) cout<<a[jkl]<<" "; cout<<endl;
ll mod = 1e9+7;
string l,r;
ll d;
int dp[10100][2][2][101];

ll getAns(int level, int tlow, int thi, int rem)
{
    if(level>=l.length())
    {
        if(rem==0) return 1;
        else return 0;
    }
    if(dp[level][tlow][thi][rem]==-1)
    {
        int blow = 0;
        int bhigh = 9;
        if(tlow) blow =l[level] - '0';
        if(thi) bhigh = r[level]-'0';
        ll ans =0;

        for(int i=blow;i<=bhigh;i++)
        {
            int ntlow = tlow;
            int nthi = thi;
            if( i > l[level]-'0') ntlow =0 ;
            if(i<r[level]-'0') nthi =0;

            ans += getAns(level+1, ntlow,nthi,(rem + i)%d);
            ans%=mod;
        }
        dp[level][tlow][thi][rem] = ans;
    }
    return dp[level][tlow][thi][rem];

}

int main()
{
    string n;
    cin>>n;
    r = n;
    l = "1";

    while(l.length()<r.length()) l += '0';
    reverse(all(l));
    cin>>d;
    mem(dp,-1);
    //cout<<r<<" "<<l<<endl;

    cout<<getAns(0,1,1,0)<<endl;;
}







#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e4 + 10;

int dp[N][2][100];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	string k;
	int d;
	cin >> k >> d;
	int n = k.length();
	dp[0][1][0] = 1;
	for(int i = 1; i <= n; i++) {
		int cur = k[i - 1] - '0';
		for(int j = 0; j <= 9; j++) {
			for(int rem = 0; rem < d; rem++) {
				dp[i][0][(rem + j) % d] = (dp[i][0][(rem + j) % d] + dp[i - 1][0][rem]) % mod;
				if(j < cur) {
					dp[i][0][(rem + j) % d] = (dp[i][0][(rem + j) % d] + dp[i - 1][1][rem]) % mod;
				}
				if(j == cur) {
					dp[i][1][(rem + j) % d] = (dp[i][1][(rem + j) % d] + dp[i - 1][1][rem]) % mod;
				}
			}
		}
	}
	cout << (dp[n][0][0] + dp[n][1][0] - 1 + mod) % mod;

	return 0;
}