#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } #include using mint = atcoder::modint998244353; int main() { fast_io(); string n; cin >> n; int m = n.size(); string s = "404"; vector dp(m + 1, vector(2, vector(3, 0))); dp[0][0][0] = 1; for (int i = 0; i < m; i++) { for (int smaller = 0; smaller < 2; smaller++) { for (int j = 0; j < 3; j++) { for (int x = 0; x <= (smaller ? 9 : (n[i] - '0')); x++) { int nj; if (x == (s[j] - '0')) { nj = j + 1; } else if (x == 4) { nj = 1; } else { nj = 0; } if (nj == 3) { continue; } dp[i + 1][smaller || (x < (n[i] - '0'))][nj] += dp[i][smaller][j]; } } } } mint ans = 0; for (int j = 0; j < 3; j++) { ans += dp[m][0][j] + dp[m][1][j]; } ans--; cout << ans.val() << endl; }