import sys input = sys.stdin.readline T = input()[:-1] N = len(T) D = int(input()) dp = [[0]*10 for _ in range(N+1)] dp[0][0] = 1 MOD = 10**9+7 for i in range(N): if T[i]!='?': for j in range(10): k = j+int(T[i]) if k>=10: k = int(str(k)[0])+int(str(k)[1]) dp[i+1][k] += dp[i][j] dp[i+1][k] %= MOD else: for j in range(10): for k in range(10): l = j+k if l>=10: l = int(str(l)[0])+int(str(l)[1]) dp[i+1][l] += dp[i][j] dp[i+1][l] %= MOD print(dp[N][D])