#include using namespace std; long long mod = 998244353; //入力が必ず-mod>= 1; } return ret; }; mint &operator=(const mint &b) = default; mint operator-() const {return mint(0)-(*this);} mint operator+(const mint b){return mint(v)+=b;} mint operator-(const mint b){return mint(v)-=b;} mint operator*(const mint b){return mint(v)*=b;} mint operator/(const mint b){return mint(v)/=b;} mint operator+=(const mint b){ v += b.v; if(v >= mod) v -= mod; return *this; } mint operator-=(const mint b){ v -= b.v; if(v < 0) v += mod; return *this; } mint operator*=(const mint b){v = v*b.v%mod; return *this;} mint operator/=(mint b){ if(b == 0) assert(false); int left = mod-2; while(left){if(left&1) *this *= b; b *= b; left >>= 1;} return *this; } mint operator++(int){*this += 1; return *this;} mint operator--(int){*this -= 1; return *this;} bool operator==(const mint b){return v == b.v;} bool operator!=(const mint b){return v != b.v;} bool operator>(const mint b){return v > b.v;} bool operator>=(const mint b){return v >= b.v;} bool operator<(const mint b){return v < b.v;} bool operator<=(const mint b){return v <= b.v;} mint pow(const long long x){return repeat2mint(v,x);} mint inv(){return mint(1)/v;} }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int N = s.size(); if(N < 3){cout << s << endl; return 0;} bool Nng = false; vector p10(N,1); for(int i=1; i alive(3); for(int i=0; i next(3); next.at(0) = alive.at(0)*9+alive.at(1)*8+alive.at(2)*9; next.at(1) = alive.at(0)+alive.at(1); next.at(2) = alive.at(1); swap(alive,next); if(i > 3 && s.at(i-3) == '4' && s.at(i-2) == '0' && s.at(i-1) == '4') Nng = true; if(Nng) continue; int limit = (s.at(i)-'0')*10+(s.at(i+1)-'0'); bool four = false,zerofour = false; if(i > 2 && s.at(i-2) == '4' && s.at(i-1) == '0') four = true; if(i > 1 && s.at(i-1) == '4') four = zerofour = true; limit -= limit%10; for(int k=0; k 3 && s.at(N-4) == '4' && s.at(N-3) == '0' && s.at(N-2) == '4') Nng = true; mint answer = 0; if(Nng == false){ for(char i='0'; i<=s.at(N-1); i++){ if(s.at(N-3) == '4' && s.at(N-2) == '0' && i == '4') continue; answer++; } } for(auto &a : alive) answer += a; answer--; cout << answer.v << endl; }