atcoder#ABC234E. [ABC234E] Arithmetic Number

[ABC234E] Arithmetic Number

Score : 500500 points

Problem Statement

Let us call a positive integer nn that satisfies the following condition an arithmetic number.

  • Let did_i be the ii-th digit of nn from the top (when nn is written in base 1010 without unnecessary leading zeros.) Then, (d2d1)=(d3d2)==(dkdk1)(d_2-d_1)=(d_3-d_2)=\dots=(d_k-d_{k-1}) holds, where kk is the number of digits in nn.- This condition can be rephrased into the sequence (d1,d2,,dk)(d_1,d_2,\dots,d_k) being arithmetic.
    • If nn is a 11-digit integer, it is assumed to be an arithmetic number.

For example, 234,369,86420,17,95,8,11,777234,369,86420,17,95,8,11,777 are arithmetic numbers, while 751,919,2022,246810,2356751,919,2022,246810,2356 are not.

Find the smallest arithmetic number not less than XX.

Constraints

  • XX is an integer between 11 and 101710^{17} (inclusive).

Input

Input is given from Standard Input in the following format:

XX

Output

Print the answer as an integer.

152
159

The smallest arithmetic number not less than 152152 is 159159.

88
88

XX itself may be an arithmetic number.

8989898989
9876543210