#line 2 "library/template/template.hpp" //#pragma GCC target("avx") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #include #define overload4(a,b,c,d,e,...) e #define overload3(a,b,c,d,...) d #define rep1(a) for(ll i=0;i<(ll)(a);i++) #define rep2(i,a) for(ll i=0;i<(ll)(a);i++) #define rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rep4(i,a,b,c) for(ll i=(ll)(a);i<(ll)(b);i+=(ll)(c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rrep1(a) for(ll i=(ll)(a)-1;i>=0;i--) #define rrep2(i,a) for(ll i=(ll)(a)-1;i>=0;i--) #define rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--) #define rrep(...) overload3(__VA_ARGS__,rrep3,rrep2,rrep1)(__VA_ARGS__) #define all1(i) begin(i),end(i) #define all2(i,a) begin(i),begin(i)+a #define all3(i,a,b) begin(i)+a,begin(i)+b #define all(...) overload3(__VA_ARGS__,all3,all2,all1)(__VA_ARGS__) #define rall(n) (n).rbegin(),(n).rend() #define INT(...) int __VA_ARGS__;scan(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__) #define STR(...) string __VA_ARGS__;scan(__VA_ARGS__) #define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__) #define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__) #define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__) #define pb push_back #define eb emplace_back #define END(...) {print(__VA_ARGS__);return;} using namespace std; using ll=long long; using ull=unsigned long long; using ld=long double; using vl=vector; using vi=vector; using vs=vector; using vc=vector; using vvl=vector; using pi=pair; using pl=pair; using vvc=vector; using vd=vector; using vp=vector; using vb=vector; const int dx[8]={1,0,-1,0,1,-1,-1,1}; const int dy[8]={0,1,0,-1,1,1,-1,-1}; const ll MOD=1000000007; const ll mod=998244353; const ld EPS=1e-8; const ld PI=3.1415926535897932384626; template ostream &operator<<(ostream&os,const pair&p){os< istream &operator>>(istream&is,pair&p){is>>p.first>>p.second;return is;} template ostream &operator<<(ostream&os,const vector&v){for(int i=0;i<(int)v.size();i++){os< istream &operator>>(istream&is,vector&v){for(T &in:v){is>>in;}return is;} void scan(){} template void scan(Head&head,Tail&... tail){cin>>head;scan(tail...);} template void print(const T &t){cout< void print(const Head &head, const Tail &... tail){cout< void fin(const T &... a){print(a...);exit(0);} template inline bool chmax(T&a,U b){return a inline bool chmin(T&a,U b){return a>b&&(a=b,true);} template class infinity{ public: static const T MAX=numeric_limits::max(); static const T MIN=numeric_limits::min(); static const T value=numeric_limits::max()/2; static const T mvalue=numeric_limits::min()/2; }; #if __cplusplus <= 201402L templateconst T infinity::value; templateconst T infinity::mvalue; templateconst T infinity::max; templateconst T infinity::min; #endif templateconst T inf=infinity::value; inline int popcnt(ull x){ #if __cplusplus>=202002L return popcount(x); #endif x=(x&0x5555555555555555)+((x>>1)&0x5555555555555555);x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333);x=(x&0x0f0f0f0f0f0f0f0f)+((x>>4)&0x0f0f0f0f0f0f0f0f);x=(x&0x00ff00ff00ff00ff)+((x>>8)&0x00ff00ff00ff00ff);x=(x&0x0000ffff0000ffff)+((x>>16)&0x0000ffff0000ffff);return (x&0x00000000ffffffff)+((x>>32)&0x00000000ffffffff); } void dump(const char&t){cerr< void dump(const T&t,enable_if_t::value>* =nullptr){string tmp;if(t==infinity::value||t==infinity::MAX)tmp="inf";if(t==infinity::mvalue||t==infinity::MIN)tmp="-inf";if(tmp.empty())tmp=to_string(t);cerr< void dump(const T&t,enable_if_t::value>* =nullptr){cerr<<"{";for(auto it=t.begin();it!=t.end();){dump(*it);cerr<<(++it==t.end()?"":",");}cerr<<"}";} template void dump(const pair&t){cerr<<"(";dump(t.first);cerr<<",";dump(t.second);cerr<<")";} void trace(){cerr< void trace(Head&&head,Tail&&... tail){dump(head);if(sizeof...(tail))cerr<<",";trace(forward(tail)...);} #ifdef ONLINE_JUDGE #define debug(...) #else #define debug(...) cerr<<#__VA_ARGS__<<"=";trace(__VA_ARGS__); #endif struct IOSetup{IOSetup(){cin.tie(nullptr);ios::sync_with_stdio(false);cout.tie(0);cout< struct modint{ long long x; modint():x(0){} modint(long long y){ if(y<0){ y%=m; if(y==0)x=y; else x=m+y; } else if(y=m)x-=m;return *this;} modint &operator-=(const modint&p){if((x+=m-p.x)>=m)x-=m;return *this;} modint &operator*=(const modint&p){x=x*p.x;if(x>=m)x%=m;return *this;} modint &operator/=(const modint&p){*this*=p.inv();return *this;} modint operator-()const{return modint(-x); } modint operator+(const modint&p)const{return modint(*this)+=p; } modint operator-(const modint&p)const{return modint(*this)-=p; } modint operator*(const modint&p)const{return modint(*this)*=p; } modint operator/(const modint&p)const{return modint(*this)/=p; } bool operator==(const modint&p)const{return x==p.x;} bool operator!=(const modint&p)const{return x!=p.x;} modint pow(long long n)const{ modint ret(1),mul(x); while(n){ if(n&1)ret*=mul; mul*=mul; n>>=1; } return ret; } friend ostream &operator<<(ostream &os,const modint&p) { return os<>(istream &is, modint &a) { long long t; is>>t; a=modint(t); return (is); } static long long get_mod(){return m;} }; #line 5 "library/Math/combinatorics.hpp" template struct combination{ using mint=modint; vectordat,idat; long long mx; combination(long long mx_=300000):dat(mx_+1,1),idat(mx_+1,1),mx(mx_){ for(long long i=1;i<=mx;i++)dat[i]=dat[i-1]*mint(i); idat[mx]/=dat[mx]; for(long long i=mx;i>0;i--)idat[i-1]=idat[i]*mint(i); } mint com(long long n,long long k){ if(n<0||k<0||n struct NTT{ using mint=modint; static modint g; static int limit; static vector>root,inv_root; static mint primitive_root(const long long&mo){ if(mo==167772161)return mint(3); if(mo==469762049)return mint(3); if(mo==754974721)return mint(11); if(mo==998244353)return mint(3); if(mo==1224736769)return mint(3); return mint(0); } static void init(){ if(root.empty()){ g=primitive_root(m); long long now=m-1; while(!(now&1))now>>=1,limit++; root.resize(limit+1,1),inv_root.resize(limit+1,1); root[limit]=g.pow(now); inv_root[limit]/=root[limit]; for(int i=limit-1;i>=0;i--){ root[i]=root[i+1]*root[i+1]; inv_root[i]=inv_root[i+1]*inv_root[i+1]; } } } NTT(){}; static void dft(vector&a,int inv){ init(); const int sz=a.size(); if(sz==1)return; const int mask=sz-1; vectorb(sz); for(int i=sz>>1;i>=1;i>>=1){ int e=__builtin_ffsll(sz/i)-1; mint w=1,z=(inv==1?root[e]:inv_root[e]); for(int j=0;jmultiply(vectora,vectorb){ int sz=1; const int mxsiz=a.size()+b.size()-1; while(sz::value>* = nullptr> static vectormultiply(const vector&a,const vector&b){ using mint=modint; vectora2(a.size()),b2(b.size()); for(int i=0;ic(c2.size()); for(int i=0;i int NTT::limit=0; template vector>NTT::root=vector>(); template vector>NTT::inv_root=vector>(); template modintNTT::g=modint(); #line 5 "library/Math/fps.hpp" template struct FPS:vector>{ using mint=modint; using vector::vector; using vector::operator=; void shrink(){while(!(*this).empty()&&(*this).back()==mint(0))(*this).pop_back();} FPS inv(int d=-1)const{ NTTntt; const int n=(*this).size(); if(d==-1)d=n; FPS res{(*this)[0].inv()}; for(int m=1;m>(const int&d)const{return FPS(*this)>>=d;} FPS operator*(const FPS&r)const{return FPS(*this)*=r;} FPS operator/(const FPS&r)const{return FPS(*this)/=r;} FPS operator%(const FPS&r)const{return FPS(*this)%=r;} FPS operator-()const{ FPS ret(*this); for(auto &i:ret)i=-i; return ret; } FPS &operator+=(const mint&r){ if((*this).empty())(*this).resize(1); (*this)[0]+=r; return *this; } FPS &operator-=(const mint&r){ if((*this).empty())(*this).resize(1); (*this)[0]-=r; return *this; } FPS &operator*=(const mint&r){ for(auto &i:*this)i*=r; return *this; } FPS &operator/=(const mint&r){ (*this)*=r.inv(); return *this; } FPS &operator+=(const FPS&r){ const int n=(*this).size(),m=r.size(); (*this).resize(max(n,m)); for(int i=0;i>=(const long long&d){ (*this).erase((*this).begin(),(*this).begin()+d); return *this; } FPS &operator*=(const FPS&r){ (*this)=NTT::multiply((*this),r); return *this; } FPS &operator/=(FPS r){ const int n=(*this).size(),m=r.size(); if(ndiv_mod(const FPS&r){ FPS p=*this/r,q=*this-p*r; q.shrink(); return {p,q}; } mint operator()(const mint&x)const{ mint ret(0),w(1); for(auto &e:*this){ ret+=e*w; w*=x; } return ret; } FPS diff()const{ const int n=(*this).size(); FPS ret(max(0,n-1)); for(int i=1;iinv(n+1); inv[1]=mint(1); for(int i=2;i<=n;i++)inv[i]=-inv[Mod%i]*mint(Mod/i); FPS ret(n+1); for(int i=0;id)return FPS(d,mint(0)); FPS ret=(((*this*rev)>>i).log(d)*k).exp(d)*((*this)[i].pow(k)); ret=(ret<<(i*k)); ret.resize(d); return ret; } } return (*this); } }; #line 5 "code.cpp" using mint=modint; int main(){ STR(s); ll n=s.size(); combinationc(n); vl cnt(26,0); rep(i,n)cnt[s[i]-'a']++; vector>f(26); rep(i,26){ f[i].resize(cnt[i]+1); rep(j,cnt[i]+1)f[i][j]=c.idat[j]; } FPSans{1}; rep(i,26)ans*=f[i]; mint sum=0; rep(i,1,n+1)sum+=ans[i]*c.fac(i); cout<