import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdlib; immutable long MOD = 10 ^^ 9 + 7; void main() { auto T = readln.chomp; auto N = T.length; auto D = readln.chomp.to!int; auto base = 1; foreach (i; 0..T.length.to!int-1) { base = base * 10 % 9; } auto dp = new long[][](N+1, 9); dp[0][0] = 1; foreach (i; 0..N) { foreach (j; 0..9) { if (T[i] != '?') { (dp[i+1][(j+T[i]-'0')%9] += dp[i][j]) %= MOD; } else { foreach (k; 0..10) { (dp[i+1][(j+k)%9] += dp[i][j]) &= MOD; } } } } long zero = 0; if (T.map!(a => a == '?' || a =='0').all) { zero += 1; } long ans; if (D == 9) { ans = dp[N][0] - zero; } else if (D == 0) { ans = zero; } else { ans = dp[N][D]; } ans.writeln; }