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