import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int[][] items = new int[n][3];
for (int i = 0; i < n; i++) {
items[i][0] = input.nextInt();
items[i][1] = input.nextInt();
items[i][2] = input.nextInt();
}
int result = handleArr(items);
System.out.println(result);
}
private static int handleArr(int[][] items) {
int count = 0;
for (int i = 0; i < items.length; i++) {
for (int j = i+1; j < items.length; j++) {
if (items[i][0] > items[j][0] && items[i][1] > items[j][1] && items[i][2] > items[j][2]) {
count++;
} else if (items[i][0] < items[j][0] && items[i][1] < items[j][1] && items[i][2] < items[j][2]) {
count++;
} else {
continue;
}
}
}
return count;
}
}