#include const int M = 998244353; const int MAX_LENGTH = 10001; const int MAX_TIGHT = 2; const int MAX_NZSEEN = 2; const int MAX_MASK = (1 << 11) - 1; int dp[MAX_LENGTH][MAX_TIGHT][MAX_NZSEEN][MAX_MASK]; int count(const std::string& num, int i, bool tight, bool nzseen, int mask) { if (i >= static_cast(num.length())) { return (mask == 0 && nzseen); } int& result = dp[i][tight][nzseen][mask]; if (result != -1) { return result; } int maxd = 9; if (tight) { maxd = num[i] - '0'; } result = 0; for (int d = 0; d <= maxd; d++) { bool newNzseen = nzseen || (d != 0); result += count(num, i + 1, tight && (d == maxd), newNzseen, mask ^ (1 << d) * newNzseen); result %= M; } return result; } int main() { std::string n; std::cin >> n; memset(dp, -1, sizeof(dp)); std::cout << count(n, 0, true, false, 0) << std::endl; return 0; }