Revenge of Champernowne Constant#3596

Revenge of Champernowne Constant

30 seconds
256 megabytes
Very easy

Champernowne constant is an irrational number. Its decimal representation starts with "0.", followed by concatenation of all positive integers in the increasing order.

You will be given a sequence which consists of decimal digits. Your task is to write a program which computes the position of the first occurrence of in Champernowne constant after the decimal point.

Input

The input has multiple test cases. Each line of the input has one digit sequence. The input is terminated by a line consisting only of #.

It is guaranteed that each sequence has at least one digit and its length is less than or equal to .

Output

For each sequence, output one decimal integer described above. You can assume each output value is less than 10^{16}.

Examples

Example 1

Loading
Loading