import std; void main () { string n = readln.chomp; auto N = new int[](n.length); foreach (i, c; n) N[i] = c - '0'; solve(N); } void solve (int[] N) { const long MOD = 998244353; const int len = N.length.to!int; int encode (int i, int set, bool has, bool less) { int res = 0; int p = 1; res += p * i; p *= len + 1; res += p * set; p *= 1 << 10; res += p * has; p *= 2; res += p * less; return res; } auto memo = new long[]((len + 1) * (1 << 10) * 2 * 2); memo[] = -1; long dp (int i, int set, bool has, bool less) { auto key = encode(i, set, has, less); if (memo[key] != -1) return memo[key]; if (i == len) { if (has && set == 0) return 1; return 0; } long res = 0; foreach (nex; 0..10) { if (!less && N[i] < nex) continue; int st = set; if (has || 0 < nex) st ^= (1 << nex); bool h = has || 0 < nex; bool l = less || nex < N[i]; res += dp(i + 1, st, h, l); res %= MOD; } return memo[key] = res; } writeln(dp(0, 0, false, false)); }