#include<bits/stdc++.h>#define int long longusingnamespacestd;constintINF=0x3f3f3f3f;constintM=1e9+7;vector<int>num;intn,k;intdp[101][5][2];intdfs(intpos,intcnt,booltight){if(cnt>k)return0;if(dp[pos][cnt][tight])returndp[pos][cnt][tight];if(pos==n)return(cnt==k);intup=(tight?num[pos]:9);intans=0;for(inti=0;i<=up;i++){ans+=dfs(pos+1,cnt+(i!=0),tight&&(i==num[pos]));}returndp[pos][cnt][tight]=ans;}signedmain(){strings;cin>>s;cin>>k;for(inti=0;i<s.size();i++){num.push_back(s[i]-'0');}n=s.size();cout<<dfs(0,0,1);}
#include<bits/stdc++.h>#define int long longusingnamespacestd;constintINF=1e18;constintMOD=1e9+7;constintN=1e4+5;intm;vector<int>num;intdp[N][105][2];intdfs(intpos,intval,booltight){if(pos==num.size())return(val==0);if(dp[pos][val][tight]!=-1)returndp[pos][val][tight];intup=(tight?num[pos]:9);intans=0;for(inti=0;i<=up;i++){ans+=dfs(pos+1,(val+i)%m,(i==up&&tight));if(ans>=MOD)ans%=MOD;}returndp[pos][val][tight]=ans;}signedmain(){strings;cin>>s;cin>>m;for(inti=0;i<s.size();i++)num.push_back(s[i]-'0');memset(dp,-1,sizeof(dp));cout<<(dfs(0,0,true)-1+MOD)%MOD;}