#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>

using namespace std;
const int MAXN=10005;
int P=1e9+7,d,len;
char k[MAXN];
long long a[MAXN],dp[10005][105];

long long dfs(int pos,int tot,bool lim)
{
//	cout<<pos<<' '<<tot<<' '<<lim<<endl;
	if(pos==len+1)
	{
		if(tot==0)	return 1;
		return 0;
	} 
	if(!lim&&dp[pos][tot]!=-1) return dp[pos][tot];
	
	long long ret=0 ,  up=lim?a[pos]:9  ;
	
	for(int i=0;i<= up  ;++i)
	{
		ret=(ret+dfs(pos+1,(tot+i)%d, lim&&i==a[pos] ))%P;
		
		//(ret+=dfs(pos+1,(tot+i)%d, lim&&i==a[pos] ) )%=P;
	}
	
	if(!lim) dp[pos][tot]=ret;
	return ret;
}

int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%s",k+1);
	scanf("%d",&d);
	len=strlen(k+1);
	for(int i=1;i<=len;++i)
	{
		a[i]=k[i]-'0';
	}
	
	long long ans=(dfs(1,0,1)-1+P)%P;  
	printf("%lld\n",ans);
	return 0;
}
