#include <bits/stdc++.h>
using namespace std;
void swap(int &a, int &b) {
  int temp;
  temp = a;
  a = b;
  b = temp;
}
void printarr(int a[], int n) {
  for (int i = 0; i < 2 * n; i++) cout << a[i] << " ";
  cout << endl;
}
int main() {
  long long int n, k, v;
  cin >> n;
  int a[2 * n], i, j, count = 0;
  for (i = 0; i < 2 * n; i++) cin >> a[i];
  for (i = 0; i < 2 * n; i += 2) {
    if (a[i] != a[i + 1]) {
      j = a[i];
      for (k = i + 1; k < 2 * n; k++) {
        if (j == a[k]) {
          v = k;
          while (v > i + 1) {
            count++;
            swap(a[v], a[v - 1]);
            v--;
          }
        }
      }
    }
  }
  cout << count;
  return 0;
}
