#include #ifndef DUMP #define DUMP(...) (void)0 #endif using namespace std; template > constexpr T power(T a, uint64_t n, T init = 1, Op op = Op{}) { while (n) { if (n & 1) init = op(init, a); if (n >>= 1) a = op(a, a); } return init; } template void ntt(vector& a, bool inverse) { int n = size(a); assert((n & (n - 1)) == 0); if (n < 2) return; assert((T::mod - 1) % n == 0); static vector w{1}, iw{1}; for (int m = size(w); m < n / 2; m *= 2) { static T root = 2; while (power(root, (T::mod - 1) / 2) == 1) root += 1; T dw = power(root, (T::mod - 1) / (4 * m)), idw = 1 / dw; w.resize(2 * m), iw.resize(2 * m); for (int i = 0; i < m; ++i) w[m + i] = w[i] * dw, iw[m + i] = iw[i] * idw; } if (not inverse) { for (int m = n; m >>= 1;) { for (int s = 0, k = 0; s < n; s += 2 * m, ++k) { for (int i = s, j = s + m; i < s + m; ++i, ++j) { T x = a[i], y = a[j] * w[k]; a[i] = x + y, a[j] = x - y; } } } } else { for (int m = 1; m < n; m *= 2) { for (int s = 0, k = 0; s < n; s += 2 * m, ++k) { for (int i = s, j = s + m; i < s + m; ++i, ++j) { T x = a[i], y = a[j]; a[i] = x + y, a[j] = (x - y) * iw[k]; } } } auto inv = 1 / T(n); for (auto&& e : a) e *= inv; } } template vector operator*(vector a, vector b) { if (empty(a) or empty(b)) return {}; int n = size(a), m = size(b), sz = 1 << __lg(2 * (n + m - 1) - 1); a.resize(sz), ntt(a, false); b.resize(sz), ntt(b, false); for (int i = 0; i < sz; ++i) a[i] *= b[i]; ntt(a, true), a.resize(n + m - 1); return a; } template struct modular { using T = modular; static constexpr uint32_t mod = M; uint32_t v; modular(int64_t x = 0) : v((x %= mod) < 0 ? x + mod : x) {} T operator-() const { return T() -= *this; } T& operator+=(T b) { return (int)(v += b.v - mod) < 0 ? v += mod : v, *this; } T& operator-=(T b) { return (int)(v -= b.v) < 0 ? v += mod : v, *this; } T& operator*=(T b) { return v = (uint64_t)v * b.v % mod, *this; } T& operator/=(T b) { return *this *= power(b, mod - 2); } friend T operator+(T a, T b) { return a += b; } friend T operator-(T a, T b) { return a -= b; } friend T operator*(T a, T b) { return a *= b; } friend T operator/(T a, T b) { return a /= b; } friend bool operator==(T a, T b) { return a.v == b.v; } }; using mint = modular<998244353>; vector fact, inv_fact, minv; void prepare(int n) { fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1); for (int i = 0; i <= n; ++i) fact[i] = i ? fact[i - 1] * i : 1; inv_fact[n] = power(fact[n], mint::mod - 2); for (int i = n; i--;) inv_fact[i] = (i + 1) * inv_fact[i + 1]; for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1]; } mint binom(int n, int k) { if (k < 0 or k > n) return 0; return fact[n] * inv_fact[k] * inv_fact[n - k]; } template <> mint& mint::operator/=(mint b) { return *this *= b.v < minv.size() ? minv[b.v] : power(b, mod - 2); } int main() { cin.tie(nullptr)->sync_with_stdio(false); string s; cin >> s; int n = size(s); prepare(n + 26); vector cnt(26); for (char c : s) ++cnt[c - 'a']; vector f{1}; for (int e : cnt) { vector t(e + 1); for (int i = 0; i <= e; ++i) t[i] = inv_fact[i]; f = f * t; } mint res; for (int i = 1; i <= n; ++i) res += f[i] * fact[i]; cout << res.v << '\n'; }