#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const int MAXN = 1e4 + 10;
ll dp[MAXN][128], num[MAXN];
char s[MAXN];
int len, D;

ll dfs(int pos, int tot, bool lim) {
	if (pos == len + 1) return dp[pos][tot] = (tot == 0);
	if (!lim && dp[pos][tot] != -1) return dp[pos][tot];
	int up = lim ? num[pos] : 9;
	ll ret = 0;
	for (int i = 0; i <= up; i++) {
		ret += dfs(pos + 1, (tot + i) % D, lim && (i == up));
		ret %= mod;
	}
	if (!lim) dp[pos][tot] = ret;
	return ret;
}

int main() {
	memset(dp, -1, sizeof(dp));
	scanf("%s%d", s + 1, &D);
	len = strlen(s + 1);
	for (int i = 1; i <= len; i++) num[i] = s[i] - '0';
	ll ans = (dfs(1, 0, 1) - 1 + mod) % mod;
// minus one to deduct the zero
	cout << ans << endl;
	return 0;
}
 
#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;
}