Eileen has a big luggage and she would pick a lot of things in the luggage every time when A-SOUL goes out for a show. However, if there are too many things in the luggage, the 4-digit password lock on the luggage will be hard to rotate.
The state of lock is the four digits on the lock. In one step, she can choose consecutive digits to rotate
up by one simultaneously or down by one simultaneously. For example, she can rotate

to

or

in one step because the rotated digits are consecutive, but she can't rotate

to

in one step. Since she has little strength, she wants to rotate the lock as few times as possible.
Now the lock is at state

and the password is

. As a fan of A-SOUL, you are asked to help Eileen find out the optimal plan to unlock but you only need to tell Eileen how many times she has to rotate.