#P11386. Cycle Lock Puzzle
Cycle Lock Puzzle
Cycle Lock Puzzle
Bajtynka received a birthday gift from Bajtazar—a logic toy called the Cycle Lock. The Cycle Lock consists of two buttons and a display. The display can show arbitrarily large decimal numbers without leading zeros, and the initial number is set by the toy’s software.
The goal of the game is to transform the displayed number into $1$. There are two operations available:
- Button 1: Increment the current number by $1$.
- Button 2: Perform a cyclic right shift on the decimal representation. In detail, remove the first digit and append it to the end of the number; then remove any leading zeros from the resulting string. For example, applying Button 1 on $99$ changes it to $100$. Applying Button 2 on $143$ yields $431$, and applying it on $700523$ yields $5237$.
Your task is to compute the minimum number of button presses required to achieve the number $1$.
inputFormat
The input consists of a single line containing a decimal number (without leading zeros) representing the initial number on the display.
outputFormat
Output a single integer representing the minimum number of button presses required to change the initial number to $1$.
sample
1
0