#include <bits/stdc++.h>
#define _nhatminh int main()
#define ll long long
#define str string
#define fir first
#define sec second
#define ld long double
#define pb push_back
const ll MOD = 1e9+7;
#define freopen(name) if(fopen(name".INP","r")) {freopen (name".INP","r",stdin); freopen (name".OUT","w",stdout);}
#define ALL(x) (x).begin(),(x).end()
#define piint pair < int , int >
#define piL pair < int , ll>
#define pLL pair < ll , ll >
#define TIME (1.0*clock()/CLOCKS_PER_SEC)
using namespace std;
const int Max_n=1e5 ;
str s ;
//int x ;
ll dp[10005][103][2];
int k ;
void solve(){
cin >> s ;
cin >> k ;
dp[0][0][0] = 1 ;
int low = 0, high ;
for (int i = 0 ; i < s.size() ; i ++ ){
for (int m_k= 0 ; m_k < k ; m_k ++ ){
for (int check = 0 ; check <= 1 ; check ++ ){
if (!check) high = s[i] -'0';
else high = 9 ;
for (int DI = low ; DI <= high ; DI ++ ){
if (check||DI<(s[i]-'0')){
dp[i+1][(m_k+DI)%k][1] += dp[i][(m_k)][check]%MOD;
dp[i+1][(m_k+DI)%k][1] %=MOD;
}
else {
dp[i+1][(m_k+DI)%k][0] += (dp[i][(m_k)][check])%MOD;
dp[i+1][(m_k+DI)%k][0] %=MOD;
}
}
}
}
}
ll ans =(dp[s.size()][0][1] +dp[s.size()][0][0]-1)%MOD;
cout << ans << '\n';
}
_nhatminh{
freopen("");
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int q=1;
//cin >> q;
while (q--)
solve();
cerr << '\n' << "Time elapsed " << TIME << "s.\n";
return (0);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgX25oYXRtaW5oICBpbnQgbWFpbigpCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgc3RyIHN0cmluZwojZGVmaW5lIGZpciBmaXJzdAojZGVmaW5lIHNlYyBzZWNvbmQKI2RlZmluZSBsZCBsb25nIGRvdWJsZQojZGVmaW5lIHBiIHB1c2hfYmFjawpjb25zdCBsbCBNT0QgPSAxZT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