MOD = 998244353 def main(): import sys S = sys.stdin.readline().strip() n = len(S) # Precompute factorial and inverse factorial modulo MOD max_n = n fact = [1] * (max_n + 1) for i in range(1, max_n + 1): fact[i] = fact[i-1] * i % MOD inv_fact = [1] * (max_n + 1) inv_fact[max_n] = pow(fact[max_n], MOD-2, MOD) for i in range(max_n-1, -1, -1): inv_fact[i] = inv_fact[i+1] * (i+1) % MOD from collections import defaultdict cnt = defaultdict(int) for c in S: cnt[c] += 1 # Initialize the product polynomial product = [0] * (n+1) product[0] = 1 for c in cnt: k = cnt[c] # Create the polynomial for this character: sum_{x=0}^k inv_fact[x] * t^x poly = [0] * (k+1) for x in range(k+1): poly[x] = inv_fact[x] # Multiply product with poly new_product = [0] * (len(product) + len(poly) - 1) for i in range(len(product)): if product[i] == 0: continue for j in range(len(poly)): if i + j > n: continue new_product[i+j] = (new_product[i+j] + product[i] * poly[j]) % MOD product = new_product # Compute the sum: sum_{m=1}^n (m! * product[m]) % MOD result = 0 for m in range(1, n+1): if m >= len(product): break term = fact[m] * product[m] % MOD result = (result + term) % MOD print(result) if __name__ == '__main__': main()