#include #include #include using namespace std; const int MOD = 998244353; int main() { string input; cin >> input; vector N(input.size()); for (size_t i = 0; i < input.size(); ++i) { N[i] = input[i] - '0'; } vector pre0(100, 0), pre1(100, 0); if (N.size() <= 2) { string ans = ""; for (int n : N) { ans += to_string(n); } cout << ans << endl; return 0; } int st = N[0] * 10 + N[1]; for (int i = 0; i < st; ++i) { pre0[i] = 1; } pre1[st] = 1; vector dp0(100, 0), dp1(100, 0); for (size_t k = 2; k < N.size(); ++k) { int n = N[k]; fill(dp0.begin(), dp0.end(), 0); fill(dp1.begin(), dp1.end(), 0); for (int a = 0; a < 10; ++a) { for (int b = 0; b < 10; ++b) { if (pre0[a*10+b] == 0 && pre1[a*10+b] == 0) continue; for (int c = 0; c < 10; ++c) { if (a == 4 && b == 0 && c == 4) continue; dp0[b * 10 + c] = (dp0[b * 10 + c] + pre0[a * 10 + b]) % MOD; } if (a != 4 || b != 0 || n != 4) { dp1[b * 10 + n] = (dp1[b * 10 + n] + pre1[a * 10 + b]) % MOD; } for (int c = 0; c < n; ++c) { if (a == 4 && b == 0 && c == 4) continue; dp0[b * 10 + c] = (dp0[b * 10 + c] + pre1[a * 10 + b]) % MOD; } } } pre0.swap(dp0); pre1.swap(dp1); } int ans = -1; for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { ans = (ans + pre0[i * 10 + j]) % MOD; ans = (ans + pre1[i * 10 + j]) % MOD; } } cout << ans << endl; return 0; }