using System; namespace ConsoleApp11 { class Program { static void Main(string[] args) { int count = 0; int sum = 0; int N = int.Parse(Console.ReadLine()); int[] a = new int[N]; int[] b = new int[N]; int[] c = new int[N]; for(int i = 0; i < N; i++) { var input = Console.ReadLine().Trim().Split(' '); a[i] = int.Parse(input[0]); b[i] = int.Parse(input[1]); c[i] = int.Parse(input[2]); } for(int i = 0; i < N; i++) { for(int j = i; j < N; j++) { if(j + 1 < N) { if (a[i] == a[j + 1]) { count++; a[j + 1] = 0; a[i] = -1; } } if(a[i] == b[j]) { count++; b[j] = -2; a[i] = -3; } if(a[i] == c[j]) { count++; c[j] = -4; a[i] = -5; } } } for(int i = 0; i < N; i++) { if(a[i] > 0) { sum++; } if(b[i] > 0) { sum++; } if(c[i] > 0) { sum++; } } count += sum / 4; Console.WriteLine(count); } } }