#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n;
cin>>n;
vector<int> b;
for(int i=0;i<2*n;i++) {
int temp;
cin>>temp;
b.push_back(temp);
}
int count1=0;
while(b.size()!=0) {
int val;
for(int i=1;i<b.size();i++) {
if(b[i]==b[0]){
val=i;
break;
}
}
if(val!=1)
count1+=(val-1);
b.erase(b.begin()+val);
b.erase(b.begin());
}
cout<<count1<<endl;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgbGw7CgppbnQgbWFpbigpIHsKICAgIGludCBuOwogICAgY2luPj5uOwogICAgdmVjdG9yPGludD4gYjsKICAgIGZvcihpbnQgaT0wO2k8MipuO2krKykgewogICAgICAgIGludCB0ZW1wOwogICAgICAgIGNpbj4+dGVtcDsKICAgICAgICBiLnB1c2hfYmFjayh0ZW1wKTsKICAgIH0KICAgIGludCBjb3VudDE9MDsKICAgIHdoaWxlKGIuc2l6ZSgpIT0wKSB7CiAgICAgICAgaW50IHZhbDsKICAgICAgICBmb3IoaW50IGk9MTtpPGIuc2l6ZSgpO2krKykgewogICAgICAgICAgICBpZihiW2ldPT1iWzBdKXsKICAgICAgICAgICAgICAgIHZhbD1pOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYodmFsIT0xKQogICAgICAgY291bnQxKz0odmFsLTEpOwogICAgICAgYi5lcmFzZShiLmJlZ2luKCkrdmFsKTsKICAgICAgIGIuZXJhc2UoYi5iZWdpbigpKTsKICAgIH0KICAgIGNvdXQ8PGNvdW50MTw8ZW5kbDsKfQo=