import java.io.*; import java.util.*; import java.lang.*; public class Solution{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int[][] magic=new int[3][3]; int[] count={0,0,0,0,0,0,0,0,0,0}; int change=0; int missing=0; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ magic[i][j]=sc.nextInt(); // System.out.println(magic[i][j]); } } for(int x=0;x<3;x++){ for(int y=0;y<3;y++){ if(magic[x][y]==1){ count[1]++; }else if(magic[x][y]==2){ count[2]++; }else if(magic[x][y]==3){ count[3]++; }else if(magic[x][y]==4){ count[4]++; }else if(magic[x][y]==5){ count[5]++; }else if(magic[x][y]==6){ count[6]++; } else if(magic[x][y]==7){ count[7]++; }else if(magic[x][y]==8){ count[8]++; }else if(magic[x][y]==9){ count[9]++; } } } for(int s=1;s<10;s++){ if(count[s]>1){ change=s; } if(count[s]==0){ missing=s; } } for(int a=0;a<3;a++){ for(int b=0;b<3;b++){ if(magic[a][b]==change){ if(a>0 & b>0){ if((magic[a-1][b-1]+magic[a][b]+magic[a+1][b+1])==(magic[a-1][b+1]+magic[a][b]+magic[a+1][b-1])){ //do nothing }else{ magic[a][b]=missing; System.out.println(Math.abs(change-missing)); } } } } } } }