using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int[,] m_square = new int[3,3]; string[] input0 = Console.ReadLine().Split(' '); string[] input1 = Console.ReadLine().Split(' '); string[] input2 = Console.ReadLine().Split(' '); for (int i = 0; i < 3; i++) { m_square[0,i] = Convert.ToInt32(input0[i]); m_square[1,i] = Convert.ToInt32(input1[i]); m_square[2,i] = Convert.ToInt32(input2[i]); } int[][] test = new int[8][]; test[0] = new int[9] {8,1,6,3,5,7,4,9,2}; test[1] = new int[9] {6,1,8,7,5,3,2,9,4}; test[2] = new int[9] {4,3,8,9,5,1,2,7,6}; test[3] = new int[9] {2,7,6,9,5,1,4,3,8}; test[4] = new int[9] {2,9,4,7,5,3,6,1,8}; test[5] = new int[9] {4,9,2,3,5,7,8,1,6}; test[6] = new int[9] {6,7,2,1,5,9,8,3,4}; test[7] = new int[9] {8,3,4,1,5,9,6,7,2}; int counter = 0; int val = 0; int temp = 0; int minValue = 600; for (int i = 0; i < 8; i++) { counter = 0; val = 0; temp = 0; foreach (int N in m_square) { temp = N-test[i][counter]; counter++; val = Math.Abs(temp)+val; } if (val