import sys MOD = 998244353 def main(): S = sys.stdin.readline().strip() from collections import Counter cnt = Counter(S) n = len(S) 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 polynomials = [] for char, freq in cnt.items(): p = [0] * (freq + 1) for c in range(freq + 1): p[c] = inv_fact[c] polynomials.append(p) current_poly = [1] for p in polynomials: new_poly = [0] * (len(current_poly) + len(p) - 1) for i in range(len(current_poly)): for j in range(len(p)): new_poly[i+j] = (new_poly[i+j] + current_poly[i] * p[j]) % MOD current_poly = new_poly[:n+1] result = 0 for k in range(1, n+1): if k < len(current_poly): a_k = current_poly[k] term = a_k * fact[k] % MOD result = (result + term) % MOD print(result % MOD) if __name__ == '__main__': main()