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. */ int[][] s= new int[3][3]; Scanner scan=new Scanner(System.in); int x=0; int q=0; int w=0; for(int i=0;i<3;i++) for(int j=0;j<3;j++) s[i][j]=scan.nextInt(); for(int k=0;k<3;k++) { for(int l=0;l<3;l++) { x=s[k][l]; for (int m=0;m<3;m++) { for (int n=0;n<3;n++) { if (m==k && n==l) { continue; } else { if(s[m][n]==x) { q=m; w=n; break; } } } } } } int count=0; int z; for (z=1;z<=9;z++) { count=0; for (int v=0;v<3;v++) { for (int c=0;c<3;c++) { if (s[v][c]==z) { count++; } } } if (count>0) { continue; } else { break; } } System.out.print(z-x); } }