T = input() D = int(input()) N = len(T) mod = 10 ** 9 + 7 dp = [[0] * 10 for _ in range(N + 3)] dp[0][0] = 1 for i, t in enumerate(T): rng = range(10) if t == "?" else [int(t)] for j in range(10): for d in rng: ni = i + 1 nj = j + d while nj >= 10: nj -= 9 dp[ni][nj] += dp[i][j] dp[ni][nj] %= mod print(dp[N][D])