#ABC238C. [ABC238C] digitnum

[ABC238C] digitnum

Score : 300300 points

Problem Statement

Given an integer NN, solve the following problem.

Let f(x)=f(x)= (The number of positive integers at most xx with the same number of digits as xx). Find f(1)+f(2)++f(N)f(1)+f(2)+\dots+f(N) modulo 998244353998244353.

Constraints

  • NN is an integer.
  • 1N<10181 \le N < 10^{18}

Input

Input is given from Standard Input in the following format:

NN

Output

Print the answer as an integer.

16
73
  • For a positive integer xx between 11 and 99, the positive integers at most xx with the same number of digits as xx are 1,2,,x1,2,\dots,x.- Thus, we have f(1)=1,f(2)=2,...,f(9)=9f(1)=1,f(2)=2,...,f(9)=9.
  • For a positive integer xx between 1010 and 1616, the positive integers at most xx with the same number of digits as xx are 10,11,,x10,11,\dots,x.- Thus, we have f(10)=1,f(11)=2,...,f(16)=7f(10)=1,f(11)=2,...,f(16)=7.

The final answer is 7373.

238
13870
999999999999999999
762062362

Be sure to find the sum modulo 998244353998244353.