#include using namespace std; const int N = 1e6 + 5; const int mod = 998244353; int n, a[N], dp[N][2][2][2]; string s; void ps(int &a, int b){ a += b; while(a >= mod) a -= mod; } void transfer(int x, int opa, int opb, int limit){ for(int i = 0; i <= (limit ? a[x + 1] : 9); i++){ if(opb && i == 4) continue; if(i == 4) ps(dp[x + 1][1][0][(limit && i == a[x + 1])], dp[x][opa][opb][limit]); else if(!i) ps(dp[x + 1][0][opa][(limit && i == a[x + 1])], dp[x][opa][opb][limit]); else ps(dp[x + 1][0][0][(limit && i == a[x + 1])], dp[x][opa][opb][limit]); } } int main(){ ios::sync_with_stdio(0), cin.tie(0); cin >> s; n = s.size(); s = ' ' + s; for(int i = 1; i <= n; i++) a[i] = int(s[i] - '0'); for(int i = 1; i <= n; i++){ for(int j = 1; j <= (i == 1 ? a[i] : 9); j++){ if(j == 4) ps(dp[i][1][0][(i == 1 && j == a[i])], 1); else ps(dp[i][0][0][(i == 1 && j == a[i])], 1); } } for(int i = 1; i < n; i++){ for(int state = 0; state < 8; state++){ transfer(i, ((state >> 2) & 1), ((state >> 1) & 1), ((state >> 0) & 1)); } } int ans = 0; for(int state = 0; state < 7; state++){ ps(ans, dp[n][((state >> 2) & 1)][((state >> 1) & 1)][((state >> 0) & 1)]); } cout << ans; return 0; }