// clang-format off #include #include #include #include #include #include #include #include #include #include #define FOR(i, a, b) for(int i = (a); i < (b); i++) #define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--) #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i,n) for(int i = 1; i <= (n); i++) #define rrep(i, n) for(int i = (n)-1; i >= 0; i--) #define pb push_back #define mp make_pair #define fst first #define snd second #define show(x) cout << #x << " = " << x << endl #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) #define pii pair #define vi vector using namespace std; template ostream& operator<<(ostream& o,const pair& p){return o<<"("< ostream& operator<<(ostream& o,const vector& vc){o<<"sz = "<> S; const int len = S.size(); vector data(len); int zero_num = 0; rep(i, len){ data[i] = toint(S[i]); if(data[i] == 0){ zero_num++; } } cin >> M; vector o(M,0); vector n(M,0); const int init = data[0]; if(init > 0){ o[init % M] = 1; n[init % M] = 1; } rep1(i, len-1){ rep(j, M){ n[j] = o[j]; } rep(j, M){ if(o[j] > 0){ const int ind = (j*10+data[i])%M; n[ind] = (n[ind] + o[j]) % MOD; } } if(data[i] > 0){ const int ind = data[i] % M; n[ind] = (n[ind] + 1) % MOD; } // show(i); rep(j, M){ // cout << n[j] << " "; o[j] = n[j]; } // cout << endl; } cout << n[0]+zero_num << endl; return 0; }