//
// Created by Ayan Ginet on 03.04.2018.
//
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
bool myComparison(const pair<long long,pair<long long, long long>> &a,
const pair<long long, pair<long, long>> &b)
{
return a.second.first < b.second.first;
}
bool cmp(const pair<long, long> &a,
const pair<long, long> &b)
{
return a.first < b.first;
}
vector<int> swap( vector<int> &nums, int first, int second){
if(second >= nums.size()) return nums;
int buf = nums[first];
nums[first] = nums[second];
nums[second] = buf;
return nums;
}
int minSwap( vector<int> &nums, int i, int n){
if(i > n) return 0;
if(nums[i] == nums[i+1])
return minSwap( nums, i + 2, n);
nums = swap(nums, i, i + 1);
int a = 1;
a += minSwap(nums, i + 1, n);
nums = swap(nums, i , i + 1);
nums = swap(nums, i + 1 , i + 2);
int b = 1 + minSwap(nums, i + 1, n);
return min(a,b);
}
int main(){
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> nums;
for(int i = 0; i < 2 * n; i++){
int buf;
cin >> buf;
nums.push_back(buf);
}
cout << minSwap(nums, 0, nums.size());
}
Ly8KLy8gQ3JlYXRlZCBieSBBeWFuIEdpbmV0IG9uIDAzLjA0LjIwMTguCi8vCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8bWFwPgoKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpib29sIG15Q29tcGFyaXNvbihjb25zdCBwYWlyPGxvbmcgbG9uZyxwYWlyPGxvbmcgbG9uZywgbG9uZyBsb25nPj4gJmEsCiAgICAgICAgICAgICAgICAgIGNvbnN0IHBhaXI8bG9uZyBsb25nLCBwYWlyPGxvbmcsIGxvbmc+PiAmYikKewogICAgcmV0dXJuIGEuc2Vjb25kLmZpcnN0IDwgYi5zZWNvbmQuZmlyc3Q7Cn0KCmJvb2wgY21wKGNvbnN0IHBhaXI8bG9uZywgbG9uZz4gJmEsCiAgICAgICAgICAgICAgICAgIGNvbnN0IHBhaXI8bG9uZywgbG9uZz4gJmIpCnsKICAgIHJldHVybiBhLmZpcnN0IDwgYi5maXJzdDsKfQoKdmVjdG9yPGludD4gc3dhcCggdmVjdG9yPGludD4gJm51bXMsIGludCBmaXJzdCwgaW50IHNlY29uZCl7CiAgICBpZihzZWNvbmQgPj0gbnVtcy5zaXplKCkpIHJldHVybiBudW1zOwogICAgaW50IGJ1ZiA9IG51bXNbZmlyc3RdOwogICAgbnVtc1tmaXJzdF0gPSBudW1zW3NlY29uZF07CiAgICBudW1zW3NlY29uZF0gPSBidWY7CiAgICByZXR1cm4gbnVtczsKfQoKaW50IG1pblN3YXAoIHZlY3RvcjxpbnQ+ICZudW1zLCBpbnQgaSwgaW50IG4pewogICAgaWYoaSA+IG4pIHJldHVybiAwOwoKICAgIGlmKG51bXNbaV0gPT0gbnVtc1tpKzFdKQogICAgcmV0dXJuIG1pblN3YXAoIG51bXMsIGkgKyAyLCAgbik7CgogICAgbnVtcyA9IHN3YXAobnVtcywgaSwgaSArIDEpOwogICAgaW50IGEgPSAxOwogICAgYSArPSBtaW5Td2FwKG51bXMsIGkgKyAxLCBuKTsKCiAgICBudW1zID0gc3dhcChudW1zLCBpICwgaSArIDEpOwogICAgbnVtcyA9IHN3YXAobnVtcywgaSArIDEgLCBpICsgMik7CiAgICBpbnQgYiA9IDEgKyBtaW5Td2FwKG51bXMsIGkgKyAxLCBuKTsKCiAgICByZXR1cm4gbWluKGEsYik7Cgp9CgoKCmludCBtYWluKCl7CiAgICBzdGQ6Omlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUobnVsbHB0cik7CgogICBpbnQgbjsKICAgY2luID4+IG47CiAgIAogICB2ZWN0b3I8aW50PiBudW1zOwoKICAgZm9yKGludCBpID0gMDsgaSA8IDIgKiBuOyBpKyspewogICAgICAgaW50IGJ1ZjsKICAgICAgIGNpbiA+PiBidWY7CiAgICAgICBudW1zLnB1c2hfYmFjayhidWYpOwogICB9CgogICAgY291dCA8PCBtaW5Td2FwKG51bXMsIDAsIG51bXMuc2l6ZSgpKTsKCn0=