#include using namespace std; using ll = long long; using vi = vector; using pi = pair ; using vll = vector; using vvll = vector; constexpr ll mod = 1000000007; void solve () { int k, p; cin >> k >> p; vvll res(k + 1, vll(p)); ll total = 1; res[0][0] = 1; for (int i = 1; i < 10; ++i) res[1][i % p]++; total += res[1][0]; res[1][0]++; vll pow10(k + 1); pow10[0] = 1; for (int i = 1; i <= k; ++i) pow10[i] = pow10[i - 1] * 10 % p; for (int i = 2; i <= k; ++i) { for (int d = 1; d < 10; ++d) { for (int j = 0; j < p; ++j) { res[i][(j * 10 + d + d * pow10[i - 1]) % p] += res[i - 2][j]; res[i][(j * 10 + d + d * pow10[i - 1]) % p] %= mod; } } total = (total + res[i][0]) % mod; for (int j = 0; j < p; ++j) { res[i][(j * 10) % p] += res[i - 2][j]; res[i][(j * 10) % p] %= mod; } } cout << total << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); solve(); return 0; }