#include #include using namespace std; using ll = long long; using mint = atcoder::modint998244353; #define rep(i, n) for (int i = 0; i < (int)(n); i++) void solve() { string n; cin >> n; vector dp(2, vector(3, 0)); dp[1][0] = 1; rep(ni, n.size()) { vector nex(2, vector(3, 0)); ll d = n[ni] - '0'; rep(di, 10) { rep(ps, 3) { ll ns = 0; if (di == 4) { if (ps <= 1) { ns = 1; } else { ns = 3; } } else if (di == 0) { if (ps == 1) { ns = 2; } else { ns = 0; } } if (ns >= 3) { continue; } if (di <= d) { ll upper = di == d; nex[upper][ns] += dp[1][ps]; } nex[0][ns] += dp[0][ps]; } } swap(dp, nex); } mint ans = 0; rep(upper, 2) rep(s, 3) ans += dp[upper][s]; ans -= 1; cout << ans.val() << '\n'; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }