#include <bits/stdc++.h>
using namespace std;
vector<int> n;
long long dp[10009][2][109];
int main() {
  string s;
  int d;
  cin >> s >> d;
  int l = s.size();
  for (int i = 0; i < l; i++) {
    n.push_back(s[i] - '0');
  }
  dp[0][0][0] = 1;
  for (int i = 0; i < l; i++) {
    for (int smaller = 0; smaller < 2; smaller++) {
      for (int j = 0; j < d; j++) {
        for (int x = 0; x <= (smaller ? 9 : n[i]); x++) {
          dp[i + 1][smaller || x < n[i]][(j + x) % d] += dp[i][smaller][j];
          dp[i + 1][smaller || x < n[i]][(j + x) % d] %= 1000000007;
        }
      }
    }
  }
  cout << (dp[l][0][0] + dp[l][1][0] - 1 + 1000000007) % 1000000007 << endl;
  return (0);
}
