## https://yukicoder.me/problems/no/2867 MOD = 998244353 def main(): N = input() n_len = len(N) dp_not_contains = [[0] * 3 for _ in range(n_len)] dp_not_contains[0][0] = 9 dp_not_contains[0][1] = 1 for i in range(1, n_len): dp_not_contains[i][0] += (9 * dp_not_contains[i - 1][0]) % MOD dp_not_contains[i][0] %= MOD dp_not_contains[i][1] += (1 * dp_not_contains[i - 1][0]) % MOD dp_not_contains[i][1] %= MOD dp_not_contains[i][2] += (1 * dp_not_contains[i - 1][1]) % MOD dp_not_contains[i][2] %= MOD dp_not_contains[i][1] += (1 * dp_not_contains[i - 1][1]) % MOD dp_not_contains[i][1] %= MOD dp_not_contains[i][0] += (8 * dp_not_contains[i - 1][1]) % MOD dp_not_contains[i][0] %= MOD dp_not_contains[i][0] += (9 * dp_not_contains[i - 1][2]) % MOD dp_not_contains[i][0] %= MOD answers = 0 n_state = 0 for i in range(n_len): n = int(N[i]) ans = 0 if i < n_len - 1: for j in range(n): for k in range(3): if k == 2 and j == 4: continue if k == 1 and n_state == 1 and j == 0: continue if n_state == 2 and j == 4: continue ans += dp_not_contains[n_len - 2 - i][k] ans %= MOD elif i == n_len - 1: for j in range(n): if n_state == 2 and j == 4: continue ans += 1 ans %= MOD answers += ans answers %= MOD if n_state == 0 and n == 4: n_state = 1 elif n_state == 1 and n == 0: n_state = 2 elif n_state == 2 and n == 4: break else: n_state = 0 if "404" not in N: answers += 1 answers %= MOD # 最後の0は消す print((answers - 1) % MOD) if __name__ == "__main__": main()