// 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); rep(i, len){ data[i] = toint(S[i]); } cin >> M; vector o(M,0); vector n(M,0); o[data[0] % M] = 1; n[data[0] % M] = 1; rep1(i, len-1){ rep(j, M){ n[j] = o[j]; 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; } rep(j, M){ o[j] = n[j]; } } cout << n[0] << endl; return 0; }