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) { Scanner sc=new Scanner(System.in); int s[][]=new int[3][3]; for(int i=0;i<3;i++) for(int j=0;j<3;j++) s[i][j]=sc.nextInt(); int cost = Integer.MAX_VALUE; int temp = 0; int total; total=s[0][0]+s[1][0]+s[2][0]; for (int i = 0; i < 3; i++) { temp = 0; for (int j = 0; j < 3; j++) { temp += s[i][j]; } if((Math.abs(total - temp)) < cost){ cost = Math.abs(total - temp); } } System.out.println(cost+1); } }