import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static int calculateDiff(int[][]a, int[][]b){ int diff = 0; for(int i=0; i<3; i++){ for(int j=0; j<3; j++){ if(a[i][j]-b[i][j]<0){ diff = diff + b[i][j]-a[i][j]; } else{ diff = diff + a[i][j]-b[i][j]; } } } return diff; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[][] a = new int[3][3]; for(int i=0; i<3; i++){ for(int j=0; j<3; j++){ a[i][j] = sc.nextInt(); } } int[][] ms1 = {{2,7,6},{9,5,1},{4,3,8}}; int[][] ms2 = {{6,7,2},{1,5,9},{8,3,4}}; int[][] ms3 = {{4,9,2},{3,5,7},{8,1,6}}; int[][] ms4 = {{2,9,4},{7,5,3},{6,1,8}}; int[][] ms5 = {{8,3,4},{1,5,9},{6,7,2}}; int[][] ms6 = {{4,3,8},{9,5,1},{2,7,6}}; int[][] ms7 = {{6,1,8},{7,5,3},{2,9,4}}; int[][] ms8 = {{8,1,6},{3,5,7},{4,9,2}}; int min = Integer.MAX_VALUE; int diff = calculateDiff(a,ms1); if(diff