**Time limit:**1.00 s**Memory limit:**512 MB

`1 2 3`

4 5 6

7 8 9

On each move, you can swap the numbers in any two adjacent squares (horizontally or vertically). What is the minimum number of moves required?

**Input**

The input has three lines, and each of them has three integers.

**Output**

Print one integer: the minimum number of moves.

**Example**

Input:

`2 1 3`

7 5 9

8 4 6

Output:

`4`