AT_abc407_c [ABC407C] Security 2

Description

At the entrance of AtCoder Inc., there is a special pass-code input device. The device consists of a screen displaying one string, and two buttons. Let $ t $ be the string shown on the screen. Initially, $ t $ is the empty string. Pressing a button changes $ t $ as follows: - Pressing **button A** appends `0` to the end of $ t $ . - Pressing **button B** replaces every digit in $ t $ with the next digit: for digits `0` through `8` the next digit is the one whose value is larger by $ 1 $ ; the next digit after `9` is `0`. For example, if $ t $ is `1984` and button A is pressed, $ t $ becomes `19840`; if button B is then pressed, $ t $ becomes `20951`. You are given a string $ S $ . Starting from the empty string, press the buttons zero or more times until $ t $ coincides with $ S $ . Find the minimum number of button presses required.

Input Format

The input is given from Standard Input in the following format: > $ S $

Output Format

Output the answer.

Explanation/Hint

### Sample Explanation 1 The following sequence of presses makes $ t $ equal to `21`. 1. Press button A. $ t $ becomes `0`. 2. Press button B. $ t $ becomes `1`. 3. Press button A. $ t $ becomes `10`. 4. Press button B. $ t $ becomes `21`. It is impossible to obtain `21` with fewer than four presses, so output `4`. ### Constraints - $ S $ is a string consisting of `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, and `9`. - $ 1 \le |S| \le 5 \times 10^{5} $ , where $ |S| $ is the length of $ S $ .