#include using namespace std;using ll=long long;using vi=vector;using vvi=vector;using vl=vector;using vvl=vector;using P=pair;using PL=pair;using vp=vector

;using vpl=vector; #define pqueue priority_queue templateconstexpr auto inf=numeric_limits::max()/2;constexpr int INF=inf,MOD=1000000007;constexpr ll LINF=inf; #define _ol3(_1,_2,_3,name,...)name #define _rep(i,n)_repi(i,0,n) #define _repi(i,a,b)for(int i=a,i##_l=(b);i=0;--i) #define REPA(i,v)REP(i,(v).size()) #define all(v)(v).begin(),(v).end() #define rall(v)(v).rbegin(),(v).rend() #define bit(n)(1ll<<(n)) #define F first #define S second #define endl '\n' void _print(ostream&){}templatevoid _print(ostream&s,const T&t,const U&...u){s<void print(const T&...t){_print(cout,t...);}templatevoid dprint(const T&...t){_print(cerr,t...);} #ifndef LOCAL struct osd{templateosd&operator<<(const T&t){return*this;}};osd cer_; #define dprint(...) #define cerr cer_ #endif #define dbg(x) dprint("@l",__LINE__,':',#x,'=',x) #define cho(n,a,b)print((n)?a:b) void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");} templatebool chmax(T&a,const U&b){bool x=abool chmin(T&a,const U&b){bool x=a>b;x?a=b:b;return x;} templateauto max(const T&a,const U&b){return aauto min(const T&a,const U&b){return aostream&operator<<(ostream&o,const pair&p){return o<istream&operator>>(istream&i,pair&p){return i>>p.F>>p.S;} templateclass iterable{static false_type c(string v);templatestatic auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval()))::value;}; template::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<istream&operator>>(istream&i,vector&v){for(T&j:v)i>>j;return i;}templatevector&operator<<(vector&v,const T&t){v.push_back(t);return v;} templatequeue&operator<<(queue&v, const T&t){v.push(t);return v;}templatequeue&operator>>(queue&v, T&t){t=v.front();v.pop();return v;} templatepqueue&operator<<(pqueue&v, const T&t){v.push(t);return v;}templatepqueue&operator>>(pqueue&v, T&t){t=v.front();v.pop();return v;} templatestack&operator<<(stack&v, const T&t){v.push(t);return v;}templatestack&operator>>(stack&v, T&t){t=v.front();v.pop();return v;} templateset&operator<<(set&v,const T&t){v.insert(t);return v;}templatemultiset&operator<<(multiset&v,const T&t){v.insert(t);return v;} template::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-(-a%b);}template::value,int> =0>T mod(T a, T b){if(a>0)return fmod(a,b);return b-fmod(-a,b);} templatepair&operator+=(pair&a, const pair&b){a.F+=b.F;a.S+=b.S;return a;}templatepair operator+(const pair&a, const pair&b){auto r=a;return r+=b;} templatepair&operator-=(pair&a, const pair&b){a.F-=b.F;a.S-=b.S;return a;}templatepair operator-(const pair&a, const pair&b){auto r=a;return r-=b;} templatepair operator-(const pair&a){return {-a.F, -a.S};} templatedouble norm(const pair&p){return norm(p.F)+norm(p.S);}templatedouble abs(const pair&p){return sqrt(norm(p));} inline ll square(ll a){a%=MOD;return (a*a)%MOD;} ll lpow(ll a,ll b){ a%=MOD; b%=MOD-1; if(b==0)return 1; if(b==1)return a; if(b%2){ return (square(lpow(a,b/2)%MOD)*a)%MOD; }else{ return square(lpow(a,b/2)%MOD); } } ll fact(ll n){ ll ans=1; while(n){ ans=(ans*n--)%MOD; } return ans; } ll factto(ll a,ll b){ ll ans=1; for(ll i=a;i<=b;i++){ ans=(ans*i)%MOD; } return ans; } ll perm(ll n,ll r){ // nPr return factto(n-r+1,n)%MOD; } ll comb(ll n,ll r){ // nCr return (perm(n,r)*lpow(fact(r),MOD-2))%MOD; } ll homo(ll n,ll r){ // nHr return comb(n+r-1,r); } int main(){ cin.tie(0);ios::sync_with_stdio(0); cout<>t>>d; int q = 0; int s = 0; bool f = 0; bool g = 1; REPA(i,t){ if(t[i]=='?') ++q; else { (s += t[i] - '0') %= 9; g = 0; } if(t[i] != '?' && t[i] != '0') f=true; } if(d==0) { if(f) { print(0); } else { print(1); } } else { int targ = (d - s + 9) % 9; dbg(targ); vi dp(9); dp[0] = 1; REP(i,q) { vi dpb(9); REP(j,10)REP(k,9)(dpb[(k+j)%9] += dp[k])%=MOD; dp.swap(dpb); } int ans = dp[targ]; if (g && d==9) --ans; print(ans); } }