P1511 [SDOI2006] Digit String Position / Super Long Digit String

Background

George likes mathematics, especially arithmetic sequences.

Description

What he likes most is the infinite sequence of digits formed by writing all natural numbers in ascending order. This sequence begins as: $\texttt{1234567891011121314...}$ We call this sequence $S$, and $S_1 = 1$, $S_2 = 2$, ... , $S_{10} = 1$, $S_{11} = 0$, and so on. George has a digit sequence $A$, and he wants to know the earliest position where this sequence appears in $S$. Please help him solve this problem.

Input Format

Input a single string representing the digit sequence A, with length at most 200, and no spaces.

Output Format

Output the smallest positive integer $k$ such that $A_1 = S_k, A_2 = S_{k+1}, ...,A_{len_{A}} = S_{k + len(A)-1}$ holds, where len_{A} denotes the length of sequence A.

Explanation/Hint

Source Ural State University Problem Archive. Translated by ChatGPT 5