using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { string s1 = Console.ReadLine(); string s2 = Console.ReadLine(); string s3 = Console.ReadLine(); string[] s1_temp = s1.Split(' '); string[] s2_temp = s2.Split(' '); string[] s3_temp = s3.Split(' '); int[][] arr = new int[3][]; int cost = 0; int count = 0; arr[0] = Array.ConvertAll(s1_temp, Int32.Parse); arr[1] = Array.ConvertAll(s2_temp, Int32.Parse); arr[2] = Array.ConvertAll(s3_temp, Int32.Parse); string s4 = s1 + s2 + s3; s4 = s4.Replace(' ', '!'); string s5 = "123456789"; string s6 = ""; foreach(char we in s5) { if (!(s4.Contains(we))) { s6 += we; count++; } } string s7 = ""; foreach (char we in s4) { if (we != 33) { int count1 = s4.Count(x => x == we); s4 = s4.Replace(we, '!'); if (count1 > 1) { s7 += we; } } } cost = Math.Abs(Convert.ToInt16(s7) - Convert.ToInt16(s6)); //int c1 = arr[0][0] + arr[0][1] + arr[0][2]; //int c2 = arr[1][0] + arr[1][1] + arr[1][2]; //int c3 = arr[2][0] + arr[2][1] + arr[2][2]; //int r1 = arr[0][0] + arr[1][0] + arr[2][0]; //int r2 = arr[0][1] + arr[1][1] + arr[2][1]; //int r3 = arr[0][2] + arr[1][2] + arr[2][2]; //int d1 = arr[0][0] + arr[1][1] + arr[2][2]; //int d2 = arr[0][2] + arr[1][1] + arr[2][0]; Console.WriteLine(cost); } } }