#include #include #define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) using namespace atcoder; using namespace std; typedef long long ll; using mint = modint998244353; struct Comb { vector fact, ifact; int MAX_COM; Comb() {} Comb(int n, int mod) { MAX_COM = n; init(mod, MAX_COM); } void init(long long MOD, long long MAX_COM) { int n = MAX_COM; assert(n < MOD); fact = vector(n + 1); ifact = vector(n + 1); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(long long n, long long k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; Comb comb(5000010, 998244353); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(12); string s; cin >> s; vector a(10); for (auto c : s) { a[c - '0']++; } int n = s.size(); mint ans = 0; rep(i, 1, 10) { if (a[i] == 0) continue; a[i]--; mint ad = 1; int m = n - 1; rep(i, 0, 10) { ad *= comb(m, a[i]); m -= a[i]; } ans += ad; a[i]++; } cout << ans.val() << endl; }