#00018E

Mobitel

Mirela doesn't like typing on a cellphone phone. That's why you have acquired a small robotic hand to type. There are 0-9 button on the cellphone keyboard. Robot arm is at button 5 before entering the keys. You can move over Keyboard in 4 directions: up, down, left and right, and are often moves to exactly one key. Eg if the robot arm is at 4, it can move to button 1,3,5, and 7 in one motion. If the robot arm over a digit (keys), then he can hit, but the key pressed is not counted as a movement done by the robot. In order to move the robot arm from one key to the other required number of movements. For example, to robot hand move with the keys 1 to 6 key, it is necessary to at least 3 movement. Mirela wants to know how much is the least of the necessary robot hand that writes a given number on the keypad of mobile phones.

Image: tipke



InputNatural number N (1 ≤ N ≤ 99999) - a number that robot arm to be key in the mobile phone.


OutputThe smallest number of the robotic hand is required to enroll a specified number of mobile phone.


Note: N does not begin with zero.



Input:
127
Output:
6


Input:
5555
Output:
0

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.