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.
Note: N does not begin with zero.
127Output:
65555Output:
0Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.