// Slower C++ solution:
#include <map>

#include <set>

#include <ctime>

#include <cmath>

#include <queue>

#include <stack>

#include <ctime>

#include <string>

#include <vector>

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <iostream>

#include <algorithm>

//#include <random>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef double db;

#define PB push_back

#define MP make_pair

#define INF 1073741824

#define inf 1152921504606846976

#define pi 3.14159265358979323846

//#pragma comment(linker,"/STACK:10240000,10240000")

//mt19937 rand_(time(0));

const int N=3e5+7,M=2e6;

const long long mod=1e9+7;

inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}

ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元

//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}



char str[12000];

int num[12000];

ll dp[12000][120];

int k;

ll dfs(int pos,bool up,int sum){

    if(pos==1){

        if(sum%k==0) return 1;

        return 0;

    }

    if(dp[pos][sum]!=-1&&!up) return dp[pos][sum];

    ll res=0;

    for(int i=0;i<=(up?num[pos-1]:9);i++){

        if(up&&i==num[pos-1]){

            res+=dfs(pos-1,1,(sum+i)%k);

        }

        else {

            res+=dfs(pos-1,0,(sum+i)%k);

        }

//        cout<<res<<endl;

        res%=mod;

    }

//    cout<<pos<<' '<<sum<<' '<<res<<endl;

    if(!up) dp[pos][sum]=res;

    return res;

}

ll solve(){

    int len=strlen(str);

    int ant=0;

    for(int i=len-1;i>=0;i--){

        num[++ant]=str[i]-'0';

//        cout<<num[ant]<<' ';

    }

//    cout<<endl;

    return dfs(ant+1,1,0);

}

int main(){

    //freopen("1.txt","r",stdin);

    //ios::sync_with_stdio(false);

    scanf("%s",str);

    scanf("%d",&k);

    memset(dp,-1,sizeof(dp));

    printf("%lld\n",(solve()-1+mod)%mod);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;

    return 0;

}








// Faster C++ solution for the same problem (measured speedup: 12.490569828308967x):
#include<bits/stdc++.h>

#define pb push_back

#define mp make_pair

#define se second

#define fi first

#define _ std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

const int mod = 1e9+7;

const int LOG = 17;

const int N = 5e5+123;

const ll INF = (ll)1e18 + 7;



int dp[10010][110];



int main()

{

    string s;

    cin >> s;

    int d;

    cin >> d;

    dp[0][0] = 1;

    for (int i = 0; i < s.size(); i++) {

        for (int j = 0; j < d; j++) {

            for (int k = 0; k <= 9; 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 < s.size(); i++) {

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

            ans += dp[(int)s.size() - 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;

    return 0;

}