import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int number[][]=new int[3][3]; int i,j; for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { number[i][j]=sc.nextInt(); } } int count[] = new int [8]; count[0] = number[0][0]+number[0][1]+number[0][2]; count[1] = number[1][0]+number[1][1]+number[1][2]; count[2] = number[2][0]+number[2][1]+number[2][2]; count[3] = number[0][0]+number[1][0]+number[2][0]; count[4] = number[0][1]+number[1][1]+number[2][1]; count[5] = number[0][2]+number[1][2]+number[2][2]; count[6] = number[0][0]+number[1][1]+number[2][2]; count[7] = number[0][2]+number[1][1]+number[2][0]; int sumCount =0; for( i=0;i<8;i++){ if(count[i]!=15){ ++sumCount; } } if(sumCount>0){ Arrays.sort(count); System.out.println(count[7]-count[0]); } } }