#include <bits/stdc++.h>
using namespace std;
void reverseStr(string& str);
void reverseQueue(queue<int>& Queue);
void print_queue(queue<int>& q);
int n, a[250], sum, num;
int main() {
  cin >> n;
  for (int i = 0; i < n * 2; i++) cin >> a[i];
  for (int i = 0; i < n * 2; i++) {
    for (int j = i + 2; j < n * 2; j++) {
      if (a[i] == a[j]) {
        sum += j - i - 1;
        for (int l = j; l > i; l--) {
          swap(a[l], a[l - 1]);
        }
      }
    }
  }
  cout << sum;
}
void reverseStr(string& str) {
  int n = str.length();
  for (int i = 0; i < n / 2; i++) swap(str[i], str[n - i - 1]);
}
void reverseQueue(queue<int>& Queue) {
  stack<int> Stack;
  while (!Queue.empty()) {
    Stack.push(Queue.front());
    Queue.pop();
  }
  while (!Stack.empty()) {
    Queue.push(Stack.top());
    Stack.pop();
  }
}
void print_queue(queue<int>& q) {
  while (!q.empty()) {
    cout << q.front() << " ";
    q.pop();
  }
  cout << endl;
}
