NOTE: This problem statement contains images that may not display properly if viewed outside of the applet.
Fox Ciel is observing the behavior of ants. She has a cube whose vertices are indexed from 0 to 7 as follows.
You are given a int pos containing the initial locations of the ants. The i-th element of pos is the index of the vertex where the i-th ant is located. In an attempt to observe their moves, Ciel puts honey on the 0-th vertex. The ants notice it immediately and start moving toward the honey. In a single turn, each ant will either move to an adjacent vertex along an edge of the cube or stay in its current vertex. All moves in a turn happen simultaneously, and at all times, it is legal for multiple ants to be at the same location of the cube.
Ciel observes the ants until they all move to the 0-th vertex. In order to determine how clever they were, she wants to know the minimal number of turns that were required for this to happen. Return this minimal number.