import math import sys readline=sys.stdin.readline from collections import Counter mod=998244353 def NTT(polynomial0,polynomial1): """ if len(polynomial0)*len(polynomial1)<=50: poly=[0]*(len(polynomial0)+len(polynomial1)-1) for i in range(len(polynomial0)): for j in range(len(polynomial1)): poly[i+j]+=polynomial0[i]*polynomial1[j]%mod poly[i+j]%=mod return poly """ if mod==998244353: prim_root=3 prim_root_inve=332748118 else: prim_root=Primitive_Root(mod) prim_root_inve=MOD(mod).Pow(prim_root,-1) def DFT(polynomial,n,inverse=False): if inverse: for bit in range(1,n+1): a=1<>bit,mod) U=[1] for _ in range(a): U.append(U[-1]*x%mod) for i in range(1<>bit,mod) U=[1] for _ in range(a): U.append(U[-1]*x%mod) for i in range(1<=0: x,y=1,0 else: x,y=-1,0 for i in range(len(stack)-1,-1,-1): n,m=stack[i] x,y=y,x-(n//m)*y return x,y class MOD: def __init__(self,p,e=None): self.p=p self.e=e if self.e==None: self.mod=self.p else: self.mod=self.p**self.e def Pow(self,a,n): a%=self.mod if n>=0: return pow(a,n,self.mod) else: assert math.gcd(a,self.mod)==1 x=Extended_Euclid(a,self.mod)[0] return pow(x,-n,self.mod) def Build_Fact(self,N): assert N>=0 self.factorial=[1] if self.e==None: for i in range(1,N+1): self.factorial.append(self.factorial[-1]*i%self.mod) else: self.cnt=[0]*(N+1) for i in range(1,N+1): self.cnt[i]=self.cnt[i-1] ii=i while ii%self.p==0: ii//=self.p self.cnt[i]+=1 self.factorial.append(self.factorial[-1]*ii%self.mod) self.factorial_inve=[None]*(N+1) self.factorial_inve[-1]=self.Pow(self.factorial[-1],-1) for i in range(N-1,-1,-1): ii=i+1 while ii%self.p==0: ii//=self.p self.factorial_inve[i]=(self.factorial_inve[i+1]*ii)%self.mod def Fact(self,N): if N<0: return 0 retu=self.factorial[N] if self.e!=None and self.cnt[N]: retu*=pow(self.p,self.cnt[N],self.mod)%self.mod retu%=self.mod return retu def Fact_Inve(self,N): if self.e!=None and self.cnt[N]: return None return self.factorial_inve[N] def Comb(self,N,K,divisible_count=False): if K<0 or K>N: return 0 retu=self.factorial[N]*self.factorial_inve[K]%self.mod*self.factorial_inve[N-K]%self.mod if self.e!=None: cnt=self.cnt[N]-self.cnt[N-K]-self.cnt[K] if divisible_count: return retu,cnt else: retu*=pow(self.p,cnt,self.mod) retu%=self.mod return retu S=readline().rstrip() N=len(S) mod=998244353 MD=MOD(mod) MD.Build_Fact(N) poly=[1] C=list(Counter(S).values()) C.sort() for c in C: poly=NTT(poly,[MD.Fact_Inve(i) for i in range(c+1)]) ans=sum(poly[i]*MD.Fact(i)%mod for i in range(1,N+1))%mod print(ans)