import sys MOD = 998244353 def main(): S = sys.stdin.readline().strip() n = len(S) # Precompute factorial and inverse factorial max_fact = n fact = [1] * (max_fact + 1) for i in range(1, max_fact +1): fact[i] = fact[i-1] * i % MOD inv_fact = [1]*(max_fact +1) inv_fact[max_fact] = pow(fact[max_fact], MOD-2, MOD) for i in range(max_fact-1, -1, -1): inv_fact[i] = inv_fact[i+1] * (i+1) % MOD # Count characters cnt = [0]*26 for c in S: cnt[ord(c)-ord('a')] += 1 # Initialize current polynomial [x^0] = 1 current = [1] for c in cnt: if c ==0: continue # Generate polynomial G(x) = sum x^t / t! for t=0..c G = [inv_fact[t] for t in range(c+1)] # Convolve current and G current = convolve(current, G) ans = 0 for k in range(1, len(current)): ans = (ans + current[k] * fact[k]) % MOD print(ans) def primitive_root(m): if m == 2: return 1 if m == 167772161: return 3 if m == 469762049: return 3 if m == 754974721: return 11 if m == 998244353: return 3 divs = [2] + [] x = (m - 1) // 2 while x % 2 ==0: x //=2 divs.append(2) d =3 while d*d <=x: if x %d ==0: divs.append(d) while x %d ==0: x//=d d +=2 if x>1: divs.append(x) g =2 while True: ok = True for d in divs: if pow(g, (m-1)//d, m) ==1: ok = False break if ok: return g g +=1 def ntt(a, invert=False): root = primitive_root(MOD) n = len(a) j =0 for i in range(1, n): rev = n >>1 while j >= rev: j -= rev rev >>=1 j += rev if i