0.3 The Glimmering Square
Score: 10pts
Time Limit: 5.00 sec
In a secret underground hall, Saee has set up a 5×5 glowing floor, where 24 tiles are dull and only one tile shines with a single spark.
The floor is arranged in 5 horizontal layers and 5 vertical paths. These layers and paths are numbered from 1 to 5, top to bottom and left to right respectively.
Saee wants to move the glowing tile to the exact middle of the floor, where the third horizontal layer and third vertical path intersect.

However, each move she makes must follow one of these two strict rules:
She may swap two neighboring horizontal layers.
She may swap two neighboring vertical paths.

Each such operation counts as one move.
Your goal is to calculate the least number of moves Saee must make to bring the glowing tile to the center of the floor.

Constraints

Input Format
You will be given 5 lines, each containing 5 values. Each value is either a 0 (dull tile) or a 1 (the glowing one). There will always be exactly one 1.

Output Format
Print one number - the smallest number of allowed moves needed to get the glowing tile to the middle of the floor.

Example 1
Input:
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

Output:
3

Explanation:
Example is self explanatory

Example 2
Input:
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0

Output:
1

Explanation:
Example is self explanatory

Log In to solve the Question