// link here :
#include <bits/stdc++.h>
using namespace std;

#define NAME "S - Digit Sum"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int mod = 1e9 + 7;

void addmod(ll &x, ll val){
    x+=val;
    if (x>mod) x-=mod;
    if (x<0) x+=mod;
}
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");

    string  x;
    int d;
    cin>>x;
    cin>>d;
    ll cur = 0;
    vector<ll> tmp(d,0);
    vector<ll> dp(d,0);
    for(int i=0;i<x.len;i++){

        for(int j = 0;j<d;j++)
            for(int k=0;k<=9;k++) addmod(tmp[ (j+k)%d  ], dp[j]);

        for(int j = 0;j<x[i]-'0';j++) addmod( tmp[(cur + j)%d],1LL);
        dp = tmp;
        fill(tmp.begin(),tmp.end(),0);
        //addmod(cur,0LL+x[i]-'0');
        cur = (cur + x[i]-'0')%d;
    }
    //show(dp[0]);
    //show(cur);
    cout<<dp[0] + (cur==0) - 1<<endl;

}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
const ll mod = 1e9+7;
int n, d;
vector<int> a;
ll mult(ll a,ll b){return ((a%mod)*(b%mod))%mod;}
ll add(ll a,ll b){return ((a%mod)+(b%mod))%mod;}
ll sub(ll a,ll b){return ((a%mod)-(b%mod)+mod)%mod;}
ll dp[10009][2][101];
ll fun(int ci, int used, int sum){
    if(ci==n){
        if(sum==0)
            return 1;
        return 0;
    }
    if(dp[ci][used][sum]!=-1){
        return dp[ci][used][sum];
    }
    ll ans = 0;
    for(int i=0;i<=9;++i){
        if(used==1){
            ans = add(ans, fun(ci+1, 1, (sum+i)%d));
        }
        else{
            if(i < a[ci]){
                ans = add(ans, fun(ci+1, 1, (sum+i)%d));
            }
            if(i==a[ci]){
                ans = add(ans, fun(ci + 1, 0, (sum + i) % d));
            }
        }
    }
    return dp[ci][used][sum] = ans;
}
int solve(){
    string s;
    cin>>s;
    n = s.size();
    a.resize(n);
    
    memset(dp, -1, sizeof(dp));

    for(int i=0;i<n;++i){
        a[i] = s[i]-'0';
    }

    cin>>d;
    ll ans = sub(fun(0, 0, 0), 1);
    cout<<ans; 
    // current index, used, total sum till cur_indx-1
    return 0;
}
int main(){
    fast;
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}