p, g = 998244353, 3 invg = pow(g, p-2, p) W = [pow(g, (p - 1) >> i, p) for i in range(24)] iW = [pow(invg, (p - 1) >> i, p) for i in range(24)] def fft(k, f): for l in range(k)[::-1]: d = 1 << l u = 1 for i in range(d): for j in range(i, 1 << k, 2*d): f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p u = u * W[l+1] % p def ifft(k, f): for l in range(k): d = 1 << l u = 1 for i in range(d): for j in range(i, 1 << k, 2*d): f[j+d] *= u f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p u = u * iW[l+1] % p def convolve(a, b): n0, n1 = len(a), len(b) k = (max(n0, n1) - 1).bit_length() + 1 n = 1 << k a = a + [0] * (n-n0) b = b + [0] * (n-n1) fft(k, a), fft(k, b) for i in range(n): a[i] = a[i] * b[i] % p ifft(k, a) invn = pow(n, p - 2, p) return [a[i] * invn % p for i in range(n0 + n1 - 1)] import heapq s=input() n=len(s) mod=998244353 cnt=[0]*26 for i in s: cnt[ord(i)-97]+=1 dp=[0]*(n+1) dp[0]=1 A=[1] f=[1] finv=[1] tmp=1 hq=[] for i in range(1,n+1): tmp*=i tmp%=mod f.append(tmp) finv.append(pow(tmp,mod-2,mod)) for i in range(26): b=[1] for j in range(1,cnt[i]+1): b.append(finv[j]) heapq.heappush(hq,(cnt[i]+1,b)) #print(a) while len(hq)>1: sizea,a=heapq.heappop(hq) sizeb,b=heapq.heappop(hq) heapq.heappush(hq,(sizea+sizeb-1,convolve(a, b))) a=hq[0][1] ans=0 for i in range(1,n+1): ans+=a[i]*f[i] ans%=mod print(ans)