#include using namespace std; #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define FORR(i, m, n) for (ll i = m; i >= n; i--) #define REPO(i, n) for (ll i = 1; i <= n; i++) #define ll long long #define INF (ll)1 << 60 #define MINF (-1 * INF) #define ALL(n) n.begin(), n.end() #define MOD 1000000007 #define P pair ll dp[110000][9], d; string s; int main() { cin >> s >> d; ll n = s.size(); dp[0][0] = 1; REP(i, n){ if(s[i] == '?'){ REP(j, 9){ REP(k, 10){ dp[i + 1][(j + k) % 9] += dp[i][j]; dp[i + 1][(j + k) % 9] %= MOD; } } } else{ REP(j, 9){ dp[i + 1][(j + s[i] - '0') % 9] += dp[i][j]; dp[i + 1][(j + s[i] - '0') % 9] %= MOD; } } } if(s == "0"){ cout << (d == 0 ? 1 : 0) << endl; } else if(d == 0)cout << 0 << endl; else if(d == 9) cout << dp[n][0]<