#include<bits/stdc++.h>

const int MOD = 1e9 + 7;

using namespace std;

int main(){
  string K;
  cin >> K;
  
  int D;
  cin >> D;
  
  vector<vector<vector<long long>>> dp(K.size() + 1, vector<vector<long long>>(D, vector<long long>(2, 0)));
  dp[0][0][1] = 1;
  for(int i = 0; i < (int)K.size(); i++){
    for(int j = 0; j < D; j++){
      for(int k = 0; k < 10; k++){
        dp[i + 1][(j + k) % D][0] += dp[i][j][0];
        if(k < K[i] - '0'){
          dp[i + 1][(j + k) % D][0] += dp[i][j][1];
        }else if(k == K[i] - '0'){
          dp[i + 1][(j + k) % D][1] += dp[i][j][1];
        }
        dp[i + 1][(j + k) % D][0] %= MOD;
        dp[i + 1][(j + k) % D][1] %= MOD;
      }
    }
  }
  
  cout << ((dp[K.size()][0][0] + dp[K.size()][0][1] - 1) % MOD + MOD) % MOD << endl;
  
  return 0;
}
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
string sa;
ll d,dp[10010][110];
ll dfs_dp(int pos,ll sta,bool lim)
{
	if(pos==sa.size())
		return sta%d==0;
	if(!lim && dp[pos][sta]!=-1)
		return dp[pos][sta];
	ll up=lim?(sa[pos]-'0'):9,res=0;
	for(int i=0;i<=up;i++)
		res=(res+dfs_dp(pos+1,(sta+i)%d,lim&(i==up)))%mod;
	if(!lim)
		dp[pos][sta]=res;
	return res;
}
ll work()
{
	return dfs_dp(0,0,1);
}
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>sa>>d;
	cout<<(work()+mod-1)%mod<<endl;
	return 0;
}