import java.io.*; import java.util.*; 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 in = new Scanner(System.in); int m=0,n=0,p=0,x=0,y=0,z=0,c=0,b=0; int h[] = new int[9]; for(int i=0; i < 9; i++){ h[i] = in.nextInt(); if(i<3){m=m+h[i];} else if(i>2&&i<6){n=n+h[i];} else if(i>5&&i<9) {p=p+h[i];} if(i%3==0){x=x+h[i];} else if(i%3==1){y=y+h[i];} else if(i%3==2) {z=z+h[i];} } if (m==n&&x==y){c=m-h[2]-h[5];b=Math.abs(c-h[8]);System.out.println(b); } if (m==n&&x==z){c=m-h[1]-h[4];b=Math.abs(c-h[7]);System.out.println(b); } if (m==n&&z==y){c=m-h[0]-h[3];b=Math.abs(c-h[6]);System.out.println(b); } if (m==p&&x==y){c=m-h[2]-h[8];b=Math.abs(c-h[5]);System.out.println(b); } if (m==p&&x==z){c=m-h[1]-h[7];b=Math.abs(c-h[4]);System.out.println(b); } if (m==p&&z==y){c=m-h[0]-h[6];b=Math.abs(c-h[3]);System.out.println(b); } if (p==n&&x==y){c=m-h[5]-h[8];b=Math.abs(c-h[2]);System.out.println(b); } if (p==n&&x==z){c=m-h[4]-h[7];b=Math.abs(c-h[1]);System.out.println(b); } if (p==n&&z==y){c=m-h[3]-h[6];b=Math.abs(c-h[0]);System.out.println(b); } } }