mod=10**9+7 t=input() d=int(input()) tmp=0 cnt=0 for c in t: if c=='?': cnt+=1 else: tmp+=int(c) if d!=0: if tmp!=0 and tmp%9==0: tmp=9 coef=0 for i in range(cnt): coef+=pow(10,i,mod) coef%=mod coef=[1]+[coef]*9 if tmp==0: ans=coef[d] elif tmp==d: ans=coef[0]+coef[9] else: ans=coef[(d-tmp)%9] print(ans%mod) if d==0: if tmp!=0: print(0) else: print(1)