T=input() D=input(int()) def f(t,n,v): for i in range(10): j=i+v if j>9: j-=9 n[j]+=t[i] n[j]%=1000000007 t=[0]*10 t[0]=1 for c in T: n=[0]*10 if c!='?': f(t,n,int(c)) else: for i in range(10): f(t,n,i) t=n print(t[D])