#include int ri() { int n; scanf("%d", &n); return n; } int main() { std::string s; std::cin >> s; int n = s.size(); int d = ri(); if (d == 0) { puts(std::count_if(s.begin(), s.end(), [] (char c) { return c != '?' && c != '0'; }) ? "0" : "1"); return 0; } if (d == 9) d = 0; int base = 0, res = 0, cur = 1; for (auto c : s) { if (c != '?') base += c - '0'; else { res += cur; if (res >= 1000000007) res -= 1000000007; cur = (int64_t) cur * 10 % 1000000007; } } base %= 9; if (base == d) { res++; if (res >= 1000000007) res -= 1000000007; } printf("%d\n", res); return 0; }