#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 10000
#define MAXD 100

ll dp[MAXN+1][MAXD][2];

int main(){
  string s;cin>>s;
  int n = s.size();
  int d;cin>>d;

  dp[0][0][1]=1;
  rep(i, n)rep(j, d)rep(k, 10){
    int cd = s[i]-'0';
    int nj = (j+k)%d;
    if(k>cd){
      dp[i+1][nj][0] += dp[i][j][0];
    }else if(k==cd){
      dp[i+1][nj][1] += dp[i][j][1];
      dp[i+1][nj][0] += dp[i][j][0];
    }else{
      dp[i+1][nj][0] += dp[i][j][1];
      dp[i+1][nj][0] += dp[i][j][0];
    }
    dp[i+1][nj][0] %= MOD;
    dp[i+1][nj][0] %= MOD;
  }

  cout<<(dp[n][0][0]+dp[n][0][1]-1+MOD)%MOD<<endl;

  return 0;
}
#include <bits/stdc++.h>
#define mod 998244353
#define int long long
using namespace std;
const int N=3*1e6+100;
int n,m,fac[N],inv[N],a,b;
inline int m_pow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=(ans*a)%mod;
		b>>=1;
		a=(a*a)%mod; 
	}
	return ans;
}
inline int c(int n,int m)
{
	if (m>n) return 0;
	return (fac[n]*(inv[m]*inv[n-m]%mod)%mod)%mod;
}
signed main()
{
	scanf("%lld%lld",&n,&m);
	fac[0]=1;
	for (int i=1;i<=n+3*m;i++) fac[i]=(fac[i-1]*i)%mod;
	inv[n+3*m]=m_pow(fac[n+3*m],mod-2);
	for (int i=n+3*m-1;i>=0;i--) inv[i]=(inv[i+1]*(i+1))%mod;
	for (int i=0;i<=m;i++)
	{
		if ((3*m-i)%2!=0) continue;
		a=(a+(c(n,i)*c(n+(3*m-i)/2-1,n-1))%mod)%mod;
	}
	for (int i=2*m+1;i<=3*m;i++) b=(b+c(n+3*m-i-2,n-2))%mod;
	b=(b*n)%mod;
	printf("%lld\n",(a-b+mod)%mod);
}