#include using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } #include using mint = atcoder::modint998244353; mint fact[500001], inv_fact[500001]; void init() { fact[0] = 1; for (int i = 1; i < 500001; ++i) { fact[i] = fact[i - 1] * i; } inv_fact[500000] = fact[500000].inv(); for (int i = 499999; i >= 0; --i) { inv_fact[i] = inv_fact[i + 1] * (i + 1); } } int main() { fast_io(); init(); string n; cin >> n; int cnt[10] = {}; for (char c : n) { cnt[c - '0']++; } int len = n.size(); mint tot = fact[len]; for (int i = 0; i < 10; ++i) { tot *= inv_fact[cnt[i]]; } if (cnt[0] == 0) { cout << tot.val() << endl; return 0; } mint ng = fact[len - 1] * inv_fact[cnt[0] - 1]; for (int i = 1; i < 10; ++i) { ng *= inv_fact[cnt[i]]; } mint ans = tot - ng; cout << ans.val() << endl; }