Revenge of the Champernowne Constant

Given a digit string S of length up to 100, find the 1-indexed position of its first occurrence in the Champernowne constant 0.123456789101112...

Hard8StringMathString matchingImplementationNo attempts yetTime limit8sMemory limit512 MB

Problem

The Champernowne constant is an irrational number. After the decimal point it writes every positive integer in increasing order, one right after another, so the constant is 0.123456789101112131415... .

You are given a sequence SS of decimal digits. Write a program that computes the position of the first occurrence of SS in the digits after the decimal point. The digit right after the decimal point is position 1.

Input

The input holds several test cases. Each line contains one digit sequence. The last line of the input contains only #.

Every sequence has at least one digit and its length is at most 100.

Output

For each sequence, print the position described above as one decimal integer on its own line. You may assume every output value is less than 101610^{16}.