#yuki1085 mod=10**9+7 t=input() d=int(input()) s=0 dp=[0]*9 dp[0]=1 sm=1 for i in t: if i!='?': s+=int(i) else: for j in range(9): dp[j]=(dp[j]+sm)%mod sm*=10 sm%=mod if d==0: if s==0: print(1) else: print(0) elif s==0 and d==9: print(dp[0]-1) else: print(dp[(d-s)%9])