import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Integer> arr = new ArrayList<>();
int n = sc.nextInt();
int n2 = n << 1;
for(int i = 0; i < n2; i++) {
arr.add(sc.nextInt());
}
int len = 0;
while(arr.size() > 0) {
int first = arr.get(0);
arr.remove(0);
int idx = arr.indexOf(first);
len += idx;
arr.remove(idx);
}
System.out.println(len);
}
}