import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); char[] inputs = sc.next().toCharArray(); int d = sc.nextInt(); int length = inputs.length; int[][] dp = new int[length + 1][10]; dp[0][0] = 1; for (int i = 1; i <= length; i++) { for (int j = 0; j < 10; j++) { for (int k = 0; k < 10; k++) { if (inputs[i - 1] - '0' == k || inputs[i - 1] == '?') { dp[i][sum(j + k)] += dp[i - 1][j]; dp[i][sum(j + k)] %= MOD; } } } } System.out.println(dp[length][d]); } static int sum(int x) { if (x >= 10) { int ans = 0; while (x > 0) { ans += x % 10; x /= 10; } return sum(ans); } else { return x; } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }