#include #include #define rep(i,n) for(int i=0;i=0;i--) #define repv(i,v) for(auto i:v) #define gcu getchar_unlocked #define pcu putc_unlocked #define all(x) x.begin(),x.end() #define endln() pcu('\n',stdout) #define space() pcu(' ',stdout) templateinline bool chmax(T &a,T b){return((ainline bool chmin(T &a,T b){return((a>b)?(a=b,true):(false));} using namespace std; using namespace atcoder; using ll=long long; using vi=vector;using vvi=vector;using vvvi=vector; using vl=vector;using vvl=vector;using vvvl=vector; using pii=pair;using vpii=vector;using pll=pair;using vpll=vector;using pli=pair;using pil=pair; using mi=map;using ms=map;using mc=map;using ml=map; using si=set;using sc=set;using ss=set;using sl=set; using pi=pair;using pl=pair; using mint=modint998244353; using mint1=modint1000000007; // input int iin(){int r=0,s=1;int c=gcu();while(isspace(c))c=gcu();if(c=='-'){s=-1;c=gcu();}for(;!isspace(c);c=gcu())r=r*10+(c-'0');ungetc(c,stdin);return s*r;} ll llin(){ll r=0;int s=1;int c=gcu();while(isspace(c))c=gcu();if(c=='-'){s=-1;c=gcu();}for(;!isspace(c);c=gcu())r=r*10+(c-'0');ungetc(c,stdin);return s*r;} string input(){string r="";int c=gcu();while(isspace(c))c=gcu();for(;!isspace(c);c=gcu())r+=c;ungetc(c,stdin);return r;} // output templatevoid iout(T n){if(n<0){pcu('-',stdout);n=-n;}if(n<10){pcu('0'+n,stdout);pcu('\n',stdout);return;}int i;char b[21];b[20]=0;for(i=20;n>0;b[--i]='0'+n%10,n/=10);fputs(b+i,stdout);} void print(string s){for(char i:s)pcu(i,stdout);} class mComb { private:bool _calced = false;int _mod=1000000007;vector_fac,_invf,_inv; public: void setmod(int m){_mod=m;} void init(int n){_fac.resize(n+1);_invf.resize(n+1);_inv.resize(n+1);_fac[0]=1;_fac[1]=1;_invf[0]=1;_invf[1]=1;_inv[1]=1;reps(i,2,n+1){_fac[i]=_fac[i-1]*i%_mod;_inv[i]=_mod-_inv[_mod%i]*(_mod/i)%_mod;_invf[i]=_invf[i-1]*_inv[i]%_mod;}_calced=true;} long long F(int n){if(!_calced){cerr<<"not initialized\n";exit(1);}return _fac[n];} long long C(int n,int k){if(!_calced){cerr<<"not initialized\n";exit(1);}return _invf[k]*_invf[n-k]%_mod*_fac[n]%_mod;} long long P(int n,int k){if(!_calced){cerr<<"not initialized\n";exit(1);}return _invf[n-k]*_fac[n]%_mod;} long long H(int n,int k){if(!_calced){cerr<<"not initialized\n";exit(1);}return _invf[k]*_invf[n-1]%_mod*_fac[n+k-1]%_mod;} }; int main() { ll n, p; cin >> n >> p; mComb c; c.setmod(998244353); c.init(500000); if (n < p) { cout << c.F(n) - 1 << '\n'; return 0; } mint t = 0; for (int i = 0; i <= n / p; i++) { t += c.F(n) / (c.F(i) * c.F(n - i * p) * mint(p).pow(i)); } cout << (c.F(n) - t).val() << '\n'; }